Developing Long Running Tasks Using Asynchronous Programming with VB.NET 2005 (Page 1 of 4 )
This article gives you a practical understanding of asynchronous programming. It also gives you a simple template for developing asynchronous-based applications in a very easy manner.
A downloadable file for this article is available
here.
For this article, I assume that you know enough of the basics for working with VB.NET controls, threading, events and delegates, ADO.NET, and so forth using Visual Basic.NET 2005. The entire source code for this article is available in the form of a downloadable zip. The solution was developed using Microsoft Visual Studio 2005 Professional Edition with Microsoft SQL Server 2005 Developer Edition on Microsoft Windows Server 2003 Enterprise Edition.
Even though I believe that the source code available with this contribution can work with Microsoft Visual Studio.NET 2003/2002, I didn’t really test it in any other environment. I request that you post in the discussion area if you have any problems with execution.
Methods of presenting long running tasks
When we develop any Windows-based application, we generally deal with the existing VB.net controls. For further flexibility, we may even use a few third party controls/components out of necessity.
When we develop applications which do heavy processing like scientific calculations, backing up/restoring a database, multi-level cross-tab reporting, summarizing data, file/directory search, and so forth, we are required to inform/display the status to the user, so he or she can see what our application is currently doing..
If we develop the application without showing the status of the process to the user, it would not be a very pleasing application. In some scenarios, some developers simply use the “Please wait” message. Even though this is better than nothing, it seems to work best for very short processing times (roughly three to four seconds). Imagine developing an application which processes a task for an hour, and shows a "Please wait" message for that entire time! Certainly, most users would not be pleased.
A better method would be to use a label/text area/list box/list view/status bar to show the latest status of the process. In the case of a label, it can only show the latest status of the process. The best example for this would be a file/directory search. A text area/list box/list view may be used when you want to show each and every status of the process (history) by adding the latest status at the end. You might want to use this method for CD burning software. A status bar might be used when you are dealing with a process that requires a small number of steps, but it may not be eye catching. One example of this is Yahoo/MSN messenger. To make the status bar eye catching, these IM programs are equipped with beautiful icons, to let user know the status.
Another method of showing the status of a process would be using a “progress bar.” It is really eye catching for the user. The user would certainly appreciate it, if it is available. Some CD/DVD burning software include all of the above methods together in a synchronized and effective manner (along with text indicating the expected time to finish).
The ultimate goal for any application developer would be making the user happy, even during long-running applications.
Next: What exactly is the problem? >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee