multithreading in web apps?

Discussion in 'ASP .Net' started by Edward W., Dec 5, 2004.

  1. Edward W.

    Edward W. Guest

    Can you do multi-threading in web applications? I basically understand how
    to do it in winforms but am not sure about it in web apps. Can someone
    point me to to an exmaple or an article that shows how?
     
    Edward W., Dec 5, 2004
    #1
    1. Advertising

  2. Edward,
    Here is one article on this topic:
    http://msdn.microsoft.com/msdnmag/issues/03/06/Threading/default.aspx

    I'd also like to say that multi-threading in ASP.NET is very similar to
    doing it in a Windows app because you are executing .Net code in both
    instances. If you just want to kick of a process and return the page
    immediately, check out this sample I whipped up:

    private void Page_Load(object sender, System.EventArgs e)

    {

    Thread thd = new Thread(new ThreadStart(LongRunning));

    thd.Start();

    //this.LongRunning();

    Response.Write("Done " + DateTime.Now.ToString());

    }



    private void LongRunning()

    {

    Thread.Sleep(5000);

    }


    --
    Best regards,
    Jeffrey Palermo
    Blog: http://dotnetjunkies.com/weblog/jpalermo


    "Edward W." <> wrote in message
    news:e1$...
    > Can you do multi-threading in web applications? I basically understand

    how
    > to do it in winforms but am not sure about it in web apps. Can someone
    > point me to to an exmaple or an article that shows how?
    >
    >
    >
     
    Jeffrey Palermo [MCP], Dec 5, 2004
    #2
    1. Advertising

  3. "Edward W." <> wrote in message
    news:e1$...
    > Can you do multi-threading in web applications? I basically understand
    > how to do it in winforms but am not sure about it in web apps. Can
    > someone point me to to an exmaple or an article that shows how?


    You should not attempt multithreading in web applications, except in very
    limited circumstances. This has to do with the totally different lifecycle
    between a web application and a winforms application. In particular, a Page
    is an object which exists only for the duration of a request. When the
    request is over, the page is gone. If you start a thread from that Page, it
    should expect to execute after the page, and the request, are gone.

    Leave multithreading out of web applications unless you have no other choice
    or are an expert.

    John Saunders
     
    John Saunders, Dec 5, 2004
    #3
  4. Yes you can do multithreading in ASP.NET, although the need should be very
    rare since each page request is executed on a separate thread anyway.
    Hre are a few tutorials you'll likely find to be useful:

    http://msdn.microsoft.com/library/d...n-us/vbcn7/html/vaconFreeThreadingExample.asp

    http://gethelp.devx.com/techtips/thevbpro/10_minute_solutions/feb01/10min0201ma.asp

    http://www.fawcette.com/vsm/2002_11/magazine/features/chester/

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net



    "Edward W." <> wrote in message
    news:e1$...
    > Can you do multi-threading in web applications? I basically understand
    > how to do it in winforms but am not sure about it in web apps. Can
    > someone point me to to an exmaple or an article that shows how?
    >
    >
    >
     
    Steve C. Orr [MVP, MCSD], Dec 5, 2004
    #4
  5. I agree that the need will rarely come up. One such need is if several
    operations need to take place, and each one might take a bit of time. In
    that case, all four could be started on separate threads, and the page could
    return after all four threads complete their work. Of course, designing a
    page like that would require more than intermediate skill with ASP.NET.

    --
    Best regards,
    Jeffrey Palermo
    Blog: http://dotnetjunkies.com/weblog/jpalermo


    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:uS%...
    > Yes you can do multithreading in ASP.NET, although the need should be very
    > rare since each page request is executed on a separate thread anyway.
    > Hre are a few tutorials you'll likely find to be useful:
    >
    >

    http://msdn.microsoft.com/library/d...n-us/vbcn7/html/vaconFreeThreadingExample.asp
    >
    >

    http://gethelp.devx.com/techtips/thevbpro/10_minute_solutions/feb01/10min0201ma.asp
    >
    > http://www.fawcette.com/vsm/2002_11/magazine/features/chester/
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    >
    >
    >
    > "Edward W." <> wrote in message
    > news:e1$...
    > > Can you do multi-threading in web applications? I basically understand
    > > how to do it in winforms but am not sure about it in web apps. Can
    > > someone point me to to an exmaple or an article that shows how?
    > >
    > >
    > >

    >
    >
     
    Jeffrey Palermo [MCP], Dec 6, 2004
    #5
  6. Edward W.

    Babloome

    Joined:
    May 26, 2010
    Messages:
    1
    I have this need all the time, why do we have ajax web applications?

    You can always use javascript to make Ajax calls that act just like threads.

    Babloome
     
    Babloome, May 26, 2010
    #6
    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. techie

    Web Garden and multithreading query

    techie, Sep 1, 2005, in forum: ASP .Net
    Replies:
    9
    Views:
    2,858
    techie
    Sep 6, 2005
  2. Replies:
    1
    Views:
    3,182
    bruce barker \(sqlwork.com\)
    May 11, 2006
  3. aph
    Replies:
    4
    Views:
    436
    Peter Hansen
    Jan 14, 2006
  4. anonymous

    Call windows apps from web apps

    anonymous, Feb 22, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    250
    anonymous
    Feb 28, 2005
  5. Richard Choate

    Web enabled apps/Thin client apps

    Richard Choate, Jul 23, 2003, in forum: ASP General
    Replies:
    2
    Views:
    319
    Chris Barber
    Jul 23, 2003
Loading...

Share This Page