Thread not working

G

Guest

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
 
G

Guest

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
 
H

Hans Kesting

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
 
G

Guest

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.
 
G

Guest

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.
 
G

George

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


George

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
 
G

Guest

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.
 
G

George

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.


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.
 
B

Bruce Barker

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)
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top