Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Thread not working

Reply
Thread Tools

Thread not working

 
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      01-05-2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxiZXJ0IFBhc2N1YWw=?=
Guest
Posts: n/a
 
      01-05-2006
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

 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      01-05-2006
> 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


 
Reply With Quote
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      01-05-2006
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

 
Reply With Quote
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      01-05-2006
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
>
>
>

 
Reply With Quote
 
George
Guest
Posts: n/a
 
      01-05-2006
How do you start the thread?
Should not be a problem if you are using Thread class.


George

"Jason Chu" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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
 
Reply With Quote
 
=?Utf-8?B?SmFzb24gQ2h1?=
Guest
Posts: n/a
 
      01-05-2006
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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

 
Reply With Quote
 
George
Guest
Posts: n/a
 
      01-05-2006
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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

 
Reply With Quote
 
Bruce Barker
Guest
Posts: n/a
 
      01-05-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
html5lib not thread safe. Is the Python SAX library thread-safe? John Nagle Python 5 03-12-2012 04:07 PM
os.ChDir() not thread-safe; was : Is tempfile.mkdtemp() thread-safe? Gabriel Rossetti Python 0 08-29-2008 08:30 AM
why we should call Thread.start(),not directly call Thread.run()? junzhang1983@gmail.com Java 5 06-20-2008 03:12 PM
To thread or not to thread Sidd Python 4 07-30-2005 09:08 AM
Terminating program run from thread (not just the thread) Jeffrey Barish Python 0 05-28-2004 02:02 AM



Advertisments