The difference between foreground and background threads
In .NET, there are two types of threads: foreground and background. Threads are, by default, created as foreground threads. You could set the thread state explicitly as background. The difference is that foreground threads keep an application alive as long as they are running, while background threads do not. In other words, when you close applications, all background threads are automatically terminated. So, when all the foreground threads complete execution, the application can exit before the background threads return. After all the foreground threads have been stopped, or after the application exits, the system stops all background threads.
Our previous example used the
Task object, which ...