Spawning thread from ASP.NET (how safe?)

  • Thread starter Thread starter Sanjay Kedare
  • Start date Start date
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
 
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.
 
Back
Top