how to run asynchronous methods on a web site?

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
 
R

Rick Strahl [MVP]

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top