Spawning thread from ASP.NET (how safe?)

S

Sanjay Kedare

Hi,

How safe it is to spawn a thread to do some routine job
from Application_Start event of ASP.NET

Also whenever the ASPNET worker process restarts, will the
Application_Start event be fired??

Thanks in advance,
Sanjay Kedare
 
A

Alvin Bruney

I'm not sure I understand what you mean by safety. Threads work the way the
always do. There is no inherent safety issues. Now depending on whether the
thread is a foreground thread or a background thread it could still run
while the browser is closed for example.

Spawning a thread in application_start will create a global thread.
Everytime application_start runs, your thread will run which shouldn't be
that frequent. You can have global threads, like I have done, to monitor the
application itself, check memory pressure, housekeeping type stuff really.
I'd suggest a timer instead of a thread if you need that thread to work off
a set schedule.
 

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,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top