how to run asynchronous methods on a web site?

Discussion in 'ASP .Net' started by Max, Feb 28, 2004.

  1. Max

    Max Guest

    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
     
    Max, Feb 28, 2004
    #1
    1. Advertising

  2. 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/
    ----------------------------------
    Making waves on the Web


    "Max" <> wrote in message
    news:eek:O70c.172648$...
    > 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
    >
    >
     
    Rick Strahl [MVP], Feb 28, 2004
    #2
    1. Advertising

  3. Max

    Max Guest

    Ah! Perfect!

    System.Threading

    This opens up so many posibilities!



    "Rick Strahl [MVP]" <> wrote
    >
    > 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.
     
    Max, Feb 28, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Navin Mishra

    Newbie:Asynchronous web service methods

    Navin Mishra, May 4, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    139
    Navin Mishra
    May 4, 2005
  2. Navin Mishra

    Newbie:Questions about server side asynchronous web methods

    Navin Mishra, Jul 13, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    132
    Navin Mishra
    Jul 13, 2005
  3. Peter Yao
    Replies:
    0
    Views:
    142
    Peter Yao
    Jun 25, 2007
  4. Replies:
    0
    Views:
    351
  5. Kenneth McDonald
    Replies:
    5
    Views:
    387
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page