Imran
Imran

Reputation: 656

Display C# function progress on web page in real time?

I have a C# function on a web page that takes 10 seconds to run. While it's running, I need to tell users what's happening.

Is there a way I can update a div or label on web page saying 'I'm at module 1' etc.? I want to display progress as it is happening, not after it finishes.

Thanks!

Upvotes: 1

Views: 481

Answers (3)

Ross Dargan
Ross Dargan

Reputation: 6021

You should not run long running processes on the app pool.

Create a background service that monitors a message queue (or a database) - Same a message to the queue when you want the process to start. In the background service store status of the job in the database, and create a webservice to return the service. Use jquery to call the webservice and get the latest service.

This is the best way to achieve what you want.

Upvotes: 0

4b0
4b0

Reputation: 22323

try:

 <asp:UpdateProgress ID="updProgress" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="0">
       <ProgressTemplate>
           <div>
               <img src="../Resources/Images/YourImage.gif" />
               Loading...
           </div>
       </ProgressTemplate>
   </asp:UpdateProgress>

Upvotes: 2

JonH
JonH

Reputation: 33143

I would use a jquery progressbar or something similiar to show the current status. What are your thoughts?

Upvotes: 1

Related Questions