Frequently, we developers need to manage long running processes from within our Windows Forms applications. If you are not already familiar with using delegates and asynchronous calls to manage these units of work, MSDN Magazine has a couple of articles in the Basic Instincts columns (January and May 2004 issues) that will tell you everything you need to know to get started. Grant Killian, a good friend of mine, also has a series of articles introducing the topic as well (see my new Windows Forms Resources Guide resource page for links!).
In Windows Forms applications, it's extemely important to maintain a responsive user interface. Any work that you do on the default UI thread that your application runs on that is not specifically UI related is a good candidate for an asynchronous invocation pattern.
Specific examples of good candidates include:
- Database access calls (including all of the basic CRUD behaviors)
- Web service invocations
- Lengthy processing (such as counting the digits of PI)
- Any processing that might take more than a couple of seconds to complete
The asynchronous invocation pattern is not at all hard to understand and master. By choosing to implement this pattern for any long running processes you can ensure that you will provide your customers with a responsive UI. Once you have handed off your work to another thread, you should also consider providing visual feedback to the user on the progress of the operation through progress bar controls and the like. If you have a task of indeterminate length or steps, take a look at the GotDotNet Activity Bar sample.