how to run asynchronous methods on a web site?

  • Thread starter Thread starter Max
  • Start date Start date
M

Max

Is there a built in way to run a piece of code asynchronously? I'd like to
run some code in the background that's triggered by a user action on a web
page.

Examples of what I'm talking about:
User clicks on "Update Database" which downloads a text file from another
site and imports into a database. I don't want to user to have to wait for
this.

User clicks on "Email Clients" and it sends an email to 3000 clients. I
don't want the user to sit there and wait for 3000 emails to send out. I can
have it send an email later telling the client the results.

-Max
 
You can just start a new thread or use a delegate and let the thread run
while you exit. If you're sending 3000 you'll want a new thread though.

Make sure you leave the request running long enough for the thread to start
though or use a static method or else the thread procedure might fail before
the code starts running (ie. the method called may not be there anymore).

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
 
Back
Top