multithreading question

Discussion in 'ASP .Net' started by Rob, Sep 8, 2004.

  1. Rob

    Rob Guest

    In order to show a loading page, I am attempting to call a function as
    part of a new thread, my issue is that the function returns a boolean
    if it is succesful since it also calls other functions,,

    how can I start this function in its own thread, yet get back its true
    or false to know it succeeded?

    thanks in advance
    r
     
    Rob, Sep 8, 2004
    #1
    1. Advertising

  2. Rob

    Scott Allen Guest

    Hi Rob:

    One way to do this would be to wrap the function in a delegate.
    BeginInvoke will start the function on a background thread, EndInvoke
    will allow you to harvest the results.

    You'll want to test carefully. Using additional threads in a server
    process might not always be a performance / scalability improvement.

    --
    Scott
    http://www.OdeToCode.com

    On 8 Sep 2004 10:03:20 -0700, (Rob) wrote:

    >In order to show a loading page, I am attempting to call a function as
    >part of a new thread, my issue is that the function returns a boolean
    >if it is succesful since it also calls other functions,,
    >
    >how can I start this function in its own thread, yet get back its true
    >or false to know it succeeded?
    >
    >thanks in advance
    >r
     
    Scott Allen, Sep 8, 2004
    #2
    1. Advertising

  3. Rob

    Rutger Smit Guest

    Rob wrote:

    > In order to show a loading page, I am attempting to call a function as
    > part of a new thread, my issue is that the function returns a boolean
    > if it is succesful since it also calls other functions,,
    >
    > how can I start this function in its own thread, yet get back its true
    > or false to know it succeeded?
    >
    > thanks in advance
    > r


    Rob Howard explained this thing at TechEd Europe 2004 in Amsterdam.
    Don't know if Microsoft is happy with it, but you can download his ppt
    and wmv here:

    http://www.rutgersmit.com/misc/msdn/DEV310.ppt
    http://www.rutgersmit.com/misc/msdn/DEV310.wmv (32 MB)

    Those two items were published on the TechEd Europe 2004 post conference
    DVD.


    --

    //Rutger

    DoDotNet@KICKTHIS_Gmail.com
    www.RutgerSmit.com
     
    Rutger Smit, Sep 8, 2004
    #3
  4. Hi rob,

    If you're firing off a new thread I suggest you fire off this thread onto a
    method of an object that your main application thread holds. That way you
    can set some sort of state that both share and access. IOW, the new thread
    can update a property on the object that the main thread can check or read
    at some later point in time.

    As Scott mentioned though, you'll want to be real careful with threads on
    the server - there are lifetime issues that are very uh funky. It's Ok if
    you create a thread and run it in parallel with your ASPX page thread, but
    it gets tricky when your thread outlasts the main ASPX thread.

    Generally a 'loading...' type page is better done via some sort of
    asynchronous request that keeps refreshing until the task is done. This way
    the Web Server is not tied up with this process.

    Regards,

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    http://www.west-wind.com/
    http://www.west-wind.com/weblog/
    ----------------------------------
    Making waves on the Web


    "Rob" <> wrote in message
    news:...
    > In order to show a loading page, I am attempting to call a function as
    > part of a new thread, my issue is that the function returns a boolean
    > if it is succesful since it also calls other functions,,
    >
    > how can I start this function in its own thread, yet get back its true
    > or false to know it succeeded?
    >
    > thanks in advance
    > r
     
    Rick Strahl [MVP], Sep 8, 2004
    #4
  5. Rob

    Rob Guest

    Rick, since google takes a while to post this stuff, I went ahead and
    funny enough came up with a solution to do a loading page which runs
    the function in its own thread and checks session variable to see if
    its done, and Now I read this!

    is it really bad to do it this way, how can the function(which is in
    its own thread) not be complete, if it sets the global variable when
    its finished, how do I know about lifetime issues is there a way?

    thanks for your thoughts
    r

    "Rick Strahl [MVP]" <> wrote in message news:<#>...
    > Hi rob,
    >
    > If you're firing off a new thread I suggest you fire off this thread onto a
    > method of an object that your main application thread holds. That way you
    > can set some sort of state that both share and access. IOW, the new thread
    > can update a property on the object that the main thread can check or read
    > at some later point in time.
    >
    > As Scott mentioned though, you'll want to be real careful with threads on
    > the server - there are lifetime issues that are very uh funky. It's Ok if
    > you create a thread and run it in parallel with your ASPX page thread, but
    > it gets tricky when your thread outlasts the main ASPX thread.
    >
    > Generally a 'loading...' type page is better done via some sort of
    > asynchronous request that keeps refreshing until the task is done. This way
    > the Web Server is not tied up with this process.
    >
    > Regards,
    >
    > +++ Rick ---
    >
    > --
    >
    > Rick Strahl
    > West Wind Technologies
    > http://www.west-wind.com/
    > http://www.west-wind.com/weblog/
    > ----------------------------------
    > Making waves on the Web
    >
    >
    > "Rob" <> wrote in message
    > news:...
    > > In order to show a loading page, I am attempting to call a function as
    > > part of a new thread, my issue is that the function returns a boolean
    > > if it is succesful since it also calls other functions,,
    > >
    > > how can I start this function in its own thread, yet get back its true
    > > or false to know it succeeded?
    > >
    > > thanks in advance
    > > r
     
    Rob, Sep 9, 2004
    #5
    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. Jean-Yves Nief

    question on multithreading, pipes

    Jean-Yves Nief, Dec 15, 2003, in forum: Python
    Replies:
    1
    Views:
    353
  2. Mark English

    Multithreading tkinter question

    Mark English, Dec 15, 2004, in forum: Python
    Replies:
    3
    Views:
    637
    Eric Brunel
    Dec 17, 2004
  3. facugaich

    Multithreading question

    facugaich, Oct 10, 2006, in forum: C Programming
    Replies:
    9
    Views:
    314
    facugaich
    Oct 10, 2006
  4. Alexander Dong Back Kim

    A simple question on multithreading

    Alexander Dong Back Kim, Mar 19, 2008, in forum: C++
    Replies:
    2
    Views:
    271
    Chris Thomasson
    Mar 19, 2008
  5. PJ6

    multithreading question

    PJ6, Nov 29, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    315
Loading...

Share This Page