Problem Statement
Very often, we receive requirements from the client to show the real-time progress of a long running process at the web server such that the end user gets notified on real-time basis.
Today, I will tell you a way to monitor the long server-side progress (like, a long running process, file generation etc.) in real time in your web application. The whole demonstration will be covered through ASP.NET C# but you can also implement the same sort of code in other languages as well.
To implement this in ASP.NET, we need jQuery library. In my case, the project structure looks like below.

In brief about the components available in the above project:
- Icons Contains plain and simple image/ico files to make the visual representation better.
- Models Contains two classes and one enum.

Progress class contains the list of progress steps. The ‘ProgressSteps’ are basically the various steps inside the long running process. The ‘ProgressStatus’ is nothing but the different flags that are used to mark the type of the step completed.
- aspx is our landing page which contains one plain and simple button ;after clicking on that it redirects to the Home.aspx. In the page load of Home.aspx, we have the long running process.
Design plan

Working Principle
- The plan is to hold each step of the process in a Progress model object and keep it stored in session. So, just create a session property inside aspx.cs.
- private const string sessionKey = "progress";
- public Progress Progress
- {
- get
- {
- if (Session[sessionKey] == null)
- Session.Add(sessionKey, new Progress());
- return Session[sessionKey] as Progress;
- }
- set
- {
- Session[sessionKey] = value;
- }
- }
- Then write down your long running method in Home.aspx. In this demo, to have a feel of a long running process, I have used Thread.Sleep to make a delay of 2 seconds for each step. For each step, I have stored the step description in the session object.
- public void StartDownloadExecute()
- {
- for (int i = 0; i < 5; i++)
- {
- //if(i==7)
- // Progress.Add(new ProgressStep(string.Format("Step # {0}", i), ProgressStatus.Error));
- //else
- Progress.Add(new ProgressStep(string.Format("Step # {0}", i), ProgressStatus.InProgress));
- Thread.Sleep(2000);
- }
- // ------Write further code to mark the process completed
- }
- The heart of this code is a delegate. It resides in aspx.cs and used to execute the long running process asynchronously through a managed thread.
- public delegate void Run();


Diego MendozaPosted Jun 30, 2020, 6:50 AM
Great job! Thank you. Do you have any idea how to stop this execution (by button for instance)?
Chris DesboroughPosted Nov 6, 2019, 7:28 PM
Instead of writing to a <table>, what changes would be necessary to just overwrite lblMsg continuously ?
James NoonePosted Nov 6, 2018, 12:35 PM
Fantastic! Easy to follow, clean solution with minimal overhead. Very nice. Saved me a lot of headache implementing more difficult solutions not well suited to a web forms project or implementing ajax controls where none previously existed. Really appreciate this!
h hPosted Oct 18, 2018, 1:14 PM
The download link is broken
Swaraj Ketan SantraPosted Jul 27, 2017, 11:30 AM
Tridip Bhattacharjee, Your question is not clear. I think if u run the solution attached herewith, the confusions will be cleared.
Tridip BhattacharjeePosted Jul 27, 2017, 5:00 AM
All the steps will run at same time or one after one. if it is one after one then how could we run all steps at a same time asynchronously ? if possible please clarify it.
Manav PandyaPosted Jul 26, 2017, 8:52 AM
Nice ........................
Andy AndyPosted Jul 26, 2017, 8:18 AM
Great! Thanks for Sharing!