Problem with w3wp.exe when recycling

J

jeff29_b

I have an asp.net application that stores two worker threads in the
application object like so

Application["ThreadName"] = thread;

These objects are persistent and continuously do polling and other
work. Unfortunately, when iis recycles a process the old process hangs
around even though it doesn't have any requests coming in. Is it
because of these threads I am storing in the application store. And is
there a way to configure the process to shutdown even if the threads
are running or is there an application event that notifies you of a
process shutdown?
 
J

jeff29_b

I am still curious about my question, but I think I partially solved my
problem. I had webgarden set to 2 processes, which I didn't want.
 
S

Scott Allen

Background and worker threads won't keep an application alive - the OS
will forcibly terminate them if need be.

You can use the Application_End method in global.asax to watch for the
application shutting down, but it is not 100% reliable.
 
B

bruce barker

your threads need to detect the shutdown (ThreadAbortException) and exit.
aslo in the Application onend, you should send a shutdown command to threda
(or kill them).

-- bruce (sqlwork.com)


| I have an asp.net application that stores two worker threads in the
| application object like so
|
| Application["ThreadName"] = thread;
|
| These objects are persistent and continuously do polling and other
| work. Unfortunately, when iis recycles a process the old process hangs
| around even though it doesn't have any requests coming in. Is it
| because of these threads I am storing in the application store. And is
| there a way to configure the process to shutdown even if the threads
| are running or is there an application event that notifies you of a
| process shutdown?
|
 
S

Scott Allen

Background threads will be terminated by the OS - they don't keep an
application alive.
 
J

jeff29_b

Scott said:
Background threads will be terminated by the OS - they don't keep an
application alive.

Ok, I am already handling the threadabortshutdown and the
application_end event and stopping my threads in these cases. So, I
guess the answer is that a process will be recycled even if a
background thread is running as long as it is not serving an active
request. Thanks.
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top