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?
When a .NET process Main Thread finishes, what happens with the other currently executing
Share
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.