Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm not advocate of multi-threading in ASP.NET - in most cases a better design can avoid the situation, and truth be known, I'm not an expert at multi-threading - everything I've multi-threaded has been in a fairly safe envrionment and was easy to deal with, however I've come across a situation that as far as I can tell calls for multi-threading. My question though is:

 

If I spawn a seperate thread in my application to kick off a long running process, and the main (originating) thread encounters an error or something that kills the aspnet_wp (say someone changed the web.config file) before the seperate thread is finished completing and joins back up with the main thread - will that other thread that was working now become lost memory? (Memory Leak).

 

Could I overcome this in the Application_Error event in Global by forcing a Thread.Join at this point? - Ditto for Application_End?.

 

What are some things to watch out for and code for in your experiance to keep from crashing the server?

 

Thanks!

  • Administrators
Posted (edited)

Out of interest what is the need for threading in this case? Where possible you might be able to use .Net's more generalised Async methods (Beginxxx, Endxxx) rather than managing the threads yourself.

Also as your using .Net 2 you may want to look at the new functionality provided by the framework to make this easier; in the @Page directive set the Async="true" attribute and you should now be able to use the built in support (search MSDN for ExecuteRegisteredAsyncTasks as a starting point).

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...