473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Seeking clarity on asp.net threading

Hi

I am considering spawning a background thread to perform a long running
task in my asp.net application and I was hoping someone could shed some
light on several issues for which I have not been able to find solid
answers.

Will the spawned thread be terminated prematurely when the originating
request thread is returned to the thread pool or the worker process
recycles? If it is terminated when the request completes, why have a
background thread at all? Why not simply redirect the user without
terminating the execution of the current request? If it isn't, then it
is conceivable that it could serve a similar request which would then
yet create another thread and I could end up with a large number of
threads. Will these threads impact negatively (other than general server
load) on other requests? If the thread is terminated when the wp
recycles, how can background threads be used reliably?

James

(threading noob)
Nov 19 '05 #1
1 1015
You can create your own thread and it will run independantly of any thread
that's being used by ASP.NET. So your request will not be at all influenced
by the secondary thread (barring any other code you write).

As for creating a thread for every request, you are correct that this has
the potential to get out of hand. Each thread you create is an expensive
resource and you don't want this to grow without bound.

I'd suggest two things: 1) Checking out Mike Woodring's thread pool implementation[1].
This is a thread pool you can use from within ASP.NET to prevent from creating
too many of your own threads. Mind you, you probabaly don't want to use the
..NET thread pool, as those are threads that are being used by ASP.NET so
using up those will affect ASP.NET's ability to process requests. 2) Check
out Fritz's async ASP.NET page article. This covers some of these topics.

[1] http://www.bearcanyon.com/dotnet/#threadpool
[2] http://msdn.microsoft.com/msdnmag/is...g/default.aspx

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I am considering spawning a background thread to perform a long
running task in my asp.net application and I was hoping someone could
shed some light on several issues for which I have not been able to
find solid answers.

Will the spawned thread be terminated prematurely when the originating
request thread is returned to the thread pool or the worker process
recycles? If it is terminated when the request completes, why have a
background thread at all? Why not simply redirect the user without
terminating the execution of the current request? If it isn't, then
it is conceivable that it could serve a similar request which would
then yet create another thread and I could end up with a large number
of threads. Will these threads impact negatively (other than general
server load) on other requests? If the thread is terminated when the
wp recycles, how can background threads be used reliably?

James

(threading noob)



Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ben Sehara | last post by:
Hello, I have the following warning message when I move all the php files to the new server. It had no problem with the former server. Warning: main(): stream does not support seeking in...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
10
by: Jim | last post by:
I have seen http://www.vbdotnetheaven.com/Code/Aug2003/2146.asp - but it does not work. I need a working example....if anyone has seen one. Jim
3
by: adsheehan | last post by:
I have been reading many of the posting on the GIL and impact on threading etc. I have found is confusing and would welcome some clarity on this. I understand that embedding the interpreter in a...
22
by: MLH | last post by:
If 3 things can be in one of 2 states, the number of possible combinations is equal to 2^3. But if I have 3 things, 2 of which can be in 2 states and the other in 3 states, what's the simplest...
8
by: Matt England | last post by:
My team currently using Boost Threads, but we are considering switching to ZThreads. (We seek cross-platform, C++ multithreading capabilities in an external library.) ZThread(s): ...
3
by: Jia Lu | last post by:
Hello all I see there are lots of flat db or db-like modules in the standard python modules. What about the keywords seeking speed of them ? (I want to put about 10000 articles with 10000...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.