c# - Starting a new thread on a web page button click -


i have inherited legacy app , there code can simplified down to:

protected void somebutton_click(object sender, eventargs e) {     var otherthread = new system.threading.thread(delegate()     {         system.threading.thread.sleep(20000);         fireanasyncprocess();     });     otherthread.start();      thankyoupanel.visible = true;     otherpanel.visible = false; } 

the fireanasyncprocess() seems intermittently failing run. of course number of things wondered:
given pause of 20000 above, fireanasyncprocess() called after button click has been handled? new thread called regardless of happens thread called it?

edit: result/outcome of fireanasyncprocess() not required on web page , page not intending wait them. rather trying start thread , assume gets fired.

this web environment - each request handled in own thread context, , thread.start() isn't useful: child thread aborted after request been handled, , parent thread aborted.

so if need run piece of work on button_click, should host wcf service or windows service or being able accept message web-application , run job in background.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -