|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Thread not workingI 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 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 Show quoteHide quote "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 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. Show quoteHide quote "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
Show quote
Hide quote
> I have a webpage which uploads a big file onto access db. I have heard that IIS queues requests per session. So a second request > 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 within the same session would only be serviced after the first has completed. (which seems to be the behavior you are seeing) Hans Kesting 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. Show quoteHide quote "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 > > > How do you start the thread?
Should not be a problem if you are using Thread class. George "Jason Chu" <Jason***@discussions.microsoft.com> wrote in message news:6FA4DE02-436E-4C10-99A2-B0AE0F758DB5@microsoft.com... 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 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. Show quoteHide quote "George" wrote: > How do you start the thread? > Should not be a problem if you are using Thread class. > > > George > > "Jason Chu" <Jason***@discussions.microsoft.com> wrote in message news:6FA4DE02-436E-4C10-99A2-B0AE0F758DB5@microsoft.com... > 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 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" <Jason***@discussions.microsoft.com> wrote in message news:FA42CAAD-EB92-456D-B00B-BC75C1F608CC@microsoft.com... 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. Show quoteHide quote "George" wrote: > How do you start the thread? > Should not be a problem if you are using Thread class. > > > George > > "Jason Chu" <Jason***@discussions.microsoft.com> wrote in message news:6FA4DE02-436E-4C10-99A2-B0AE0F758DB5@microsoft.com... > 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 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) Show quoteHide quote "Jason Chu" <Jason***@discussions.microsoft.com> wrote in message news:6FA4DE02-436E-4C10-99A2-B0AE0F758DB5@microsoft.com... >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
Timer control
Why the server controls do not show? PostBack Events on Server Running .NET 1.1 and 2.0 Extend the Membership Provider to include more user data Preserve Data to Edit on DataGrid When Filtering ASP.NET 2.0 problem with a GridView with 2 CommandFields page validation How to setup the user? SQLExpress as a Web Application's Profile/Role data store Dynamicly created Radio Buttons |
|||||||||||||||||||||||