Advanced .NET: Background thread termination
I don't see a forum for .NET framework or the Advanced .NET book, so I hope this is a decent place to post.
I've read a numnber of places that using a delegate's .BeginInvoke method is a great way to spawn a background thread from the thread pool if you don't need much control over it. Agreed. However, I don't see how any task could be sent off on a background thread without concern for the application being shut down by the user during its execution. However, I don't see any exceptions thrown on the background or foreground threads when this occurs so it seems I have no way of finding out that the app is shutting down and taking measures on the background thread to at least make sure I don't get killed with a file still open or something.
Am I missing something here or is .BeginInvoke useless without protecting the app from shutdown until .EndInvoke is called? I can certainly do that with a flag on the main thread but I sort of expected that at least the finally blocks would execute on the background thread -- they don't.
Tony
|