Reputation: 59336
When a .NET process Main Thread finishes, what happens with the other currently executing Threads? What if they have allocated unmanaged resources that must be disposed before they stop?
Upvotes: 0
Views: 163
Reputation: 51329
If the other threads have Thread.IsBackground set to true, they will exit immediately. Otherwise the application will keep running (invisibly, if it is a WinForms or WPF application).
If the other threads have unmanaged resources, those will usually be closed/released by the OS when the process exits (file handles, etc. There may be exceptions to this rule that I am not familiar with). It is still preferable to release those resources manually when you detect the fact that the application is exiting.
Upvotes: 2