In my ASP.NET application, I have a situation where I am doing a lot of computing and database reads/inserts/updates.
I needed to gather statistics on the processing records. This info is actually displayed on another webpage. Processing routine looks something like this:
BackgroundWorker is a class designed for windows applications not web applications. So using it in a web application is not a good idea. If I understood your question, you need to do a time consuming task on background and show a progress bar on another ASP.NET page, correct?
If yes, follow the below steps.
From the first page, start a thread (or better if you can use ThreadPool) and run the Process() method on that.
This method should update the progress to a session variable say Session["progress"]
Once the thread started, redirect to the page where progress will be displayed
Use AJAX and poll the Session["progress"] value and show it on the page. For creating progress bar, you can use HTML DIV tag with a background color.
You need to pass HttpContext.Current to the Process() method because it is thread specific and a worker thread won't have access to it. Use this context to access the session.
Thanks Navaneeth. ProgressHelper is my internal DAL responsible for udpating the progress table (sorry I should have explained). I agree with you that BackgroundWorker is a bad idea that's why I was wondering if there might be a better way to accomplish this.
Also, what are your thoughts about Async Delegates? Have you seen any adverse effects of using them in ASP.NET?
How to maintain "session" state or the like for a show/hide menu when I click a sub link from an open block of sub category, like the one The Code Project did it on the left menu panel.
For example, if I click on "Web Development" link under "ARTICLES" category, it will show many links under the "Web Development" block. Click on a link in that open block, the page will refresh and show me article I wish to view. The problem I have is I can't figure out how to maintain session of the link I just clicked. That is keep the block "Web Development" open after the page refreshes.
I mean say you have a page called submitRequest.aspx
Now from your Asp page use:
<form action ="submitRequest.aspx" >
thus when the page is posted back it goes to submitRequest.aspx. You can get each of those form elements using Request object from submitRequest.aspx (even the IFrame) where page is your custom handler.
You can also use a class which inherits from IHttpHandler to call its process request.