Search code examples
.netmultithreadingbackgroundprogram-entry-pointforeground

What are background, foreground & main threads?


what's the difference between background, foreground & main threads? What are the diff types of threads in .NET?


Solution

  • 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.