Joon
Joon

Reputation: 2147

Displaying progress for a long running process

I added a backup task to my website, which performs a list of tasks that can take a long time.

In order to provide user feedback, I have a main page with two iframes.

The first iframe has a button that performs the backup behind the button click (so the page is posting for a minute or more). As it runs, a session variable is updated with each step as they complete.

I have a second iframe on this page, and inside that iframe there is an ASP.NET page that displays the progress session variable on a label.

The problem is that the second iframe only refreshes once all the steps in the first iframe have completed. This behavior is the same in my ASP.NET dev environment, as well as when deployed to IIS.

What can I do to make the second iframe refresh as the session variable is updated?

Upvotes: 0

Views: 922

Answers (2)

MikeLim
MikeLim

Reputation: 1219

ASP.NET session state supports single writer, multiple reader.

First iframe has a writer lock to session state during entire operation. As a result, second iframe is unable to read from session until operation is complete.

Perhaps update/read your status in database or application state?

See A non-locking in-process ASP.NET session state store

Upvotes: 1

Aristos
Aristos

Reputation: 66641

This behavior is because the session is lock the entire process, and it locks and the rest of your users when you make backup.

Find some other place to store the process, other than the session. If you pool is running only with one application you may try to store it on a static variable, if you have web garden the other solution is to store that variable in a database, or on a xml file with other variables.

Also you need to run the backup from a page that have the session disabled !

About the session lock:
Web app blocked while processing another web app on sharing same session
jQuery Ajax calls to web service seem to be synchronous
ASP.NET Server does not process pages asynchronously
Replacing ASP.Net's session entirely

Upvotes: 1

Related Questions