multithreading - What happens if you fire a background thread to execute right before ASP.NET completes its page processing? -
What if I had to execute a long-running process before the completion of the ASP.NET page life cycle Will I spin a thread? Can ASP.Net Kill Runtime Thread? Can it lead to undefined behavior?
Here is a sample code, which spins the background thread in page_load event. Is this a safe thing to do?
Protected Zero Page_load (object sender, eventAgps E) {thread newtread = new thread (new threadstart (some langering middle)); NewThread.IsBackground = True; NewThread.Start (); } Private Zero SomeLongRunningMethod () {// some long moving process goes here ...}
I have experimented with the same type of code for some time in logging in some different threads. It seems to work well, but I have not tested it in the environment of production.
The only difference between your code and mine is that I used the thread pool instead of setting a new thread.
You may be able to avoid coping of any requested data and other page information, but besides this I think it should work well.
Comments
Post a Comment