what's the difference between background, foreground & main threads? What are the diff types of threads in .NET?
A background thread (whose Thread object has the Background
property set to true
) will
not prevent an application from quitting.
Once all normal(foreground) threads have exited, any running background threads are immediately terminated. In addition, if an AppDomain is unloaded, all background threads in the AppDomain are immediately aborted.
The threads managed by the ThreadPool are background threads.
A foreground thread is an ordinary thread.
The main thread is the initial thread that started the program. (The thread running the Main
method)
For more information, see here.
The distinction is succinctly stated in the documentation. Background threads are interrupted when the program ends.
http://msdn.microsoft.com/en-us/library/h339syd0(VS.71).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With