When I hit the run button (in my Default.aspx), a process starts (this process contacts a webservice to get some files, etc). How do I:
-
Ensure that only a single process is running at a time (i.e. if I refresh the browser, I don’t want to start the process a second time)
-
Track progress – there are 4 points of the process (at 25%, 50%, 75%, 100%) that I want to track, and when each part completes, I want to update the progress bar. I have a status object for the running process, but the question is how to update the progress bar automatically?
-
Do I need to use threads to achieve the above two?
Answering them in reverse order:
Yes. And you should have an object to encapsulate your thread.
You could have a public member of your object which contains the % done of your process. You could poll this periodically. The way that you would do this from your HTML page is probably an AJAX request to make your progress bar the smoothest.
You need to do some thread synchonization. Maybe through a Mutex. Here’s a good example of how to do this (scroll down to Mutex).