BackgroundWorker thread in ASP.NET

If you don’t want to use the AJAX libraries, or the e-mail processing is REALLY long and would timeout a standard AJAX request, you can use an AsynchronousPostBack method that was the “old hack” in the .net 1.1 days.

Essentially what you do is have your submit button begin the e-mail processing in an asynchronous state, while the user is taken to an intermediate page. The benefit to this is that you can have your intermediate page refresh as much as needed, without worrying about hitting the standard timeouts.

When your background process is complete, it will put a little “done” flag in the database/application variable/whatever. When your intermediate page does a refresh of itself, it detects this flag and automatically redirects the user to the “done” page.

Again, AJAX makes all of this moot, but if for some reason you have a very intensive or timely process that has to be done over the web, this solution will work for you. I found a nice tutorial on it here and there are plenty more out there.

I had to use a process like this when we were working on a “web check-in” type application that was interfacing with a third party application and their import API was hideously slow.

EDIT: GAH! Curse you Guzlar and your god-like typing abilities 8^D.

Leave a Comment