Thread not working

Discussion in 'ASP .Net' started by =?Utf-8?B?SmFzb24gQ2h1?=, Jan 5, 2006.

  1. I have a webpage which uploads a big file onto access db.
    if the file is say around 30 megs, it'll take around a minute for it to get
    put into the access db.
    I didn't want the user to wait for it, so I decided to put it on a thread.
    The thread works, but not the way it should.
    One of my page will start the thread, and then forward the user to another
    page.
    The thread will start, and browser will get forwarded to the next page, BUT
    as soon as I click anything in that second page, the response will be stuck
    waiting until the thread processing the upload is done. Now that isn't very
    much threaded now is it?...
    Why is that happening? is putting stuff on the access db a process that has
    to be done alone and can't be threaded?
    Thx
    =?Utf-8?B?SmFzb24gQ2h1?=, Jan 5, 2006
    #1
    1. Advertising

  2. Jason,

    Actually the Thread will die if the page that created the thread is
    destroyed. Use a webservice or Ajax to accomplished that.

    Cheers
    Al

    "Jason Chu" wrote:

    > I have a webpage which uploads a big file onto access db.
    > if the file is say around 30 megs, it'll take around a minute for it to get
    > put into the access db.
    > I didn't want the user to wait for it, so I decided to put it on a thread.
    > The thread works, but not the way it should.
    > One of my page will start the thread, and then forward the user to another
    > page.
    > The thread will start, and browser will get forwarded to the next page, BUT
    > as soon as I click anything in that second page, the response will be stuck
    > waiting until the thread processing the upload is done. Now that isn't very
    > much threaded now is it?...
    > Why is that happening? is putting stuff on the access db a process that has
    > to be done alone and can't be threaded?
    > Thx
    =?Utf-8?B?QWxiZXJ0IFBhc2N1YWw=?=, Jan 5, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?SmFzb24gQ2h1?=

    Hans Kesting Guest

    Re: =?UTF-8?B?VGhyZWFkIG5vdCB3b3JraW5n?=

    > I have a webpage which uploads a big file onto access db.
    > if the file is say around 30 megs, it'll take around a minute for it to get
    > put into the access db.
    > I didn't want the user to wait for it, so I decided to put it on a thread.
    > The thread works, but not the way it should.
    > One of my page will start the thread, and then forward the user to another
    > page.
    > The thread will start, and browser will get forwarded to the next page, BUT
    > as soon as I click anything in that second page, the response will be stuck
    > waiting until the thread processing the upload is done. Now that isn't very
    > much threaded now is it?...
    > Why is that happening? is putting stuff on the access db a process that has
    > to be done alone and can't be threaded?
    > Thx


    I have heard that IIS queues requests per session. So a second request
    within the same session would only be serviced after the first has
    completed. (which seems to be the behavior you are seeing)

    Hans Kesting
    Hans Kesting, Jan 5, 2006
    #3
  4. thanx for reply.

    As for AJAX, I don't really wanna, cuz all the codes are all done and good
    to go in C# (plus there's many components involved....it's just all tied up).
    As for Webservices...will that make the processing totally separate from the
    other processes from the pages (ie button clicks)? I believe both page
    actions and webservices are handled by the same asp.net process. if
    threading the database process in a page didn't make it separate (since it
    hogged up the whole asp.net process), won't putting it on the webservice do
    the same thing? (ie asp.net handles the webservice in another of its own
    thread, but that thread hogs up the entire asp.net process, so the page
    actions have to wait)
    I don't want to move all my code to webservices unless I know that it'll
    improve it.

    "Albert Pascual" wrote:

    > Jason,
    >
    > Actually the Thread will die if the page that created the thread is
    > destroyed. Use a webservice or Ajax to accomplished that.
    >
    > Cheers
    > Al
    >
    > "Jason Chu" wrote:
    >
    > > I have a webpage which uploads a big file onto access db.
    > > if the file is say around 30 megs, it'll take around a minute for it to get
    > > put into the access db.
    > > I didn't want the user to wait for it, so I decided to put it on a thread.
    > > The thread works, but not the way it should.
    > > One of my page will start the thread, and then forward the user to another
    > > page.
    > > The thread will start, and browser will get forwarded to the next page, BUT
    > > as soon as I click anything in that second page, the response will be stuck
    > > waiting until the thread processing the upload is done. Now that isn't very
    > > much threaded now is it?...
    > > Why is that happening? is putting stuff on the access db a process that has
    > > to be done alone and can't be threaded?
    > > Thx
    =?Utf-8?B?SmFzb24gQ2h1?=, Jan 5, 2006
    #4
  5. Thanks for replying.

    Before I've put the upload processing function into a thread, I did some
    tests with multiple users.
    If one of that big upload occurs (so it'll take a minute to process), the
    other users will still be able to move around the application for a little
    bit, but will be stuck needing to wait after several clicks on the page.
    For example
    So if A initiate the 1 minute process.
    B will be able to surf around for a bit, then after several postbacks, the
    next postback will be stuck needing to wait for A's process to finish first
    before a response comes back.
    Kind of feels like asp.net has a buffer for B to move in...and as soon as
    that buffer runs out, B will have to wait.

    "Hans Kesting" wrote:

    > > I have a webpage which uploads a big file onto access db.
    > > if the file is say around 30 megs, it'll take around a minute for it to get
    > > put into the access db.
    > > I didn't want the user to wait for it, so I decided to put it on a thread.
    > > The thread works, but not the way it should.
    > > One of my page will start the thread, and then forward the user to another
    > > page.
    > > The thread will start, and browser will get forwarded to the next page, BUT
    > > as soon as I click anything in that second page, the response will be stuck
    > > waiting until the thread processing the upload is done. Now that isn't very
    > > much threaded now is it?...
    > > Why is that happening? is putting stuff on the access db a process that has
    > > to be done alone and can't be threaded?
    > > Thx

    >
    > I have heard that IIS queues requests per session. So a second request
    > within the same session would only be serviced after the first has
    > completed. (which seems to be the behavior you are seeing)
    >
    > Hans Kesting
    >
    >
    >
    =?Utf-8?B?SmFzb24gQ2h1?=, Jan 5, 2006
    #5
  6. =?Utf-8?B?SmFzb24gQ2h1?=

    George Guest

    How do you start the thread?
    Should not be a problem if you are using Thread class.


    George

    "Jason Chu" <> wrote in message news:...
    I have a webpage which uploads a big file onto access db.
    if the file is say around 30 megs, it'll take around a minute for it to get
    put into the access db.
    I didn't want the user to wait for it, so I decided to put it on a thread.
    The thread works, but not the way it should.
    One of my page will start the thread, and then forward the user to another
    page.
    The thread will start, and browser will get forwarded to the next page, BUT
    as soon as I click anything in that second page, the response will be stuck
    waiting until the thread processing the upload is done. Now that isn't very
    much threaded now is it?...
    Why is that happening? is putting stuff on the access db a process that has
    to be done alone and can't be threaded?
    Thx
    George, Jan 5, 2006
    #6
  7. ProcessorContainer pc = new ProcessorContainer(parameters);
    Thread thread = new Thread(new ThreadStart(pc.ProcessUpload));
    thread.Start();

    simple enough
    : )

    but if i were to have a problem, then the thread won't even start.

    remind you, that the big processing part is shoving the file into the access
    db, so the one line causing the wait is the ExecuteNonQuery() of the
    OleDbCommand.

    "George" wrote:

    > How do you start the thread?
    > Should not be a problem if you are using Thread class.
    >
    >
    > George
    >
    > "Jason Chu" <> wrote in message news:...
    > I have a webpage which uploads a big file onto access db.
    > if the file is say around 30 megs, it'll take around a minute for it to get
    > put into the access db.
    > I didn't want the user to wait for it, so I decided to put it on a thread.
    > The thread works, but not the way it should.
    > One of my page will start the thread, and then forward the user to another
    > page.
    > The thread will start, and browser will get forwarded to the next page, BUT
    > as soon as I click anything in that second page, the response will be stuck
    > waiting until the thread processing the upload is done. Now that isn't very
    > much threaded now is it?...
    > Why is that happening? is putting stuff on the access db a process that has
    > to be done alone and can't be threaded?
    > Thx
    =?Utf-8?B?SmFzb24gQ2h1?=, Jan 5, 2006
    #7
  8. =?Utf-8?B?SmFzb24gQ2h1?=

    George Guest

    I think you have problem somewhere else. Whatever you are doing with threads looks correct. You might post the whole code for your Page object.

    Here are the facts that might help you figure out where problem is.

    Session is locked during ASP.NET called. So only one request for one session can come in. Second request (with same SessionID) will be queued.

    The page must run through the whole lifecycle in order for Session object to be unlocked for next request.

    Response.Redirect( url ) or Response.Redirect( url, true ) will terminate page thus ending it's lifecycle.
    Response.Redirect( url, false) will not end the lifecycle you can still be blocking the session.

    ------------------------------------------------------------------------------------------

    I would replace redirect with Response.Write("AAA") and then see if the IE logo in right top corner is spinning.
    If it is that means the page is hanging somewhere.


    Hope that helps./

    George.


    "Jason Chu" <> wrote in message news:...
    ProcessorContainer pc = new ProcessorContainer(parameters);
    Thread thread = new Thread(new ThreadStart(pc.ProcessUpload));
    thread.Start();

    simple enough
    : )

    but if i were to have a problem, then the thread won't even start.

    remind you, that the big processing part is shoving the file into the access
    db, so the one line causing the wait is the ExecuteNonQuery() of the
    OleDbCommand.

    "George" wrote:

    > How do you start the thread?
    > Should not be a problem if you are using Thread class.
    >
    >
    > George
    >
    > "Jason Chu" <> wrote in message news:...
    > I have a webpage which uploads a big file onto access db.
    > if the file is say around 30 megs, it'll take around a minute for it to get
    > put into the access db.
    > I didn't want the user to wait for it, so I decided to put it on a thread.
    > The thread works, but not the way it should.
    > One of my page will start the thread, and then forward the user to another
    > page.
    > The thread will start, and browser will get forwarded to the next page, BUT
    > as soon as I click anything in that second page, the response will be stuck
    > waiting until the thread processing the upload is done. Now that isn't very
    > much threaded now is it?...
    > Why is that happening? is putting stuff on the access db a process that has
    > to be done alone and can't be threaded?
    > Thx
    George, Jan 5, 2006
    #8
  9. =?Utf-8?B?SmFzb24gQ2h1?=

    Bruce Barker Guest

    you have the correct approach. nothing in asp.net will cause the behavior
    you are seeing, it must be your code forcing serialization. maybe you are
    hitting locking problems with the db.

    -- bruce (sqlwork.com)




    "Jason Chu" <> wrote in message
    news:...
    >I have a webpage which uploads a big file onto access db.
    > if the file is say around 30 megs, it'll take around a minute for it to
    > get
    > put into the access db.
    > I didn't want the user to wait for it, so I decided to put it on a thread.
    > The thread works, but not the way it should.
    > One of my page will start the thread, and then forward the user to another
    > page.
    > The thread will start, and browser will get forwarded to the next page,
    > BUT
    > as soon as I click anything in that second page, the response will be
    > stuck
    > waiting until the thread processing the upload is done. Now that isn't
    > very
    > much threaded now is it?...
    > Why is that happening? is putting stuff on the access db a process that
    > has
    > to be done alone and can't be threaded?
    > Thx
    Bruce Barker, Jan 5, 2006
    #9
    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. Jeffrey Barish
    Replies:
    0
    Views:
    302
    Jeffrey Barish
    May 28, 2004
  2. Sidd

    To thread or not to thread

    Sidd, Jul 28, 2005, in forum: Python
    Replies:
    4
    Views:
    308
    snacktime
    Jul 30, 2005
  3. Replies:
    5
    Views:
    1,609
    Roedy Green
    Jun 20, 2008
  4. Gabriel Rossetti
    Replies:
    0
    Views:
    1,314
    Gabriel Rossetti
    Aug 29, 2008
  5. John Nagle
    Replies:
    5
    Views:
    467
    John Nagle
    Mar 12, 2012
Loading...

Share This Page