Executing Long-Running Tasks with the Progress Bar in ASP.NET (Page 1 of 5 )
This article demonstrates the use of multi-threading in ASP.NET web applications to execute long running tasks. It also shows the status of that long running task with the help of a progress bar.
A downloadable file for this article is available
here.
The problem
Every scenario in IT, at some level, needs a long running task (process) to be performed. Long running tasks may also include taking a huge database backup, installing software, formatting a disk, and so on. When we perform any of those tasks, we will watch its progress.
When a lengthy task starts, some applications get developed with a simple message such as “Please wait” or “Wait a moment” or something similar. Some applications show the progress of the same type of task (sometimes in the form of “percentage complete” or “time remaining”). Showing the progress of a task is pretty common during installations of certain software (or even small packages).
Any user would generally ask (or suggest) that we show the progress of achievement when the system starts processing a lengthy task. If it is a small task (say, going to complete within one minute), it is reasonable to provide messages such as “Please Wait…” or “Wait a moment.” But, for long running tasks, it is the programmer’s responsibility to show the progress of achievement to the user visually (before the user complains for it).
It is fairly easy to show the progress of achievement (for long running tasks) on desktop (non–browser based) applications. But, it is a bit difficult for browser based applications, because we will not be able to maintain a dedicated HTTP request. Once the browser receives the information (response) from server, the HTTP connection gets disconnected automatically. If the server takes too much time to serve for the browser (or client) through HTTP, we may even experience a “Timeout” error.
This article concentrates on working with long running tasks in ASP.NET effectively without consuming too many resources from the server (using multi-threading), and also showing the progress of the task to the user (by auto-refreshing the page every two seconds).
Next: The structure of the VS.NET solution >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee