How to close child threads when C # closes an application
Source: Internet
Author: User
A managed thread is either a background thread or a foreground thread. Background threads do not make the managed execution environment active, except that the background thread is the same as the foreground thread. Once all foreground threads are stopped in the managed process (where the. exe file is the managed assembly), all background threads are stopped and closed. By setting the Thread.IsBackground property, you can designate a thread as either a background thread or a foreground thread. For example, you can designate a thread as a background thread by setting Thread.IsBackground to True. Similarly, by setting IsBackground to False, you can designate a thread as a foreground thread. All threads that enter the managed execution environment from unmanaged code are marked as background threads. All threads generated by creating and starting a new thread object are foreground threads. If you want to create a foreground thread that you want to use to listen for certain activities, such as a socket connection, you should set the Thread.IsBackground to true so that the process can terminate.
A thread is either a background thread or a foreground thread. Background threads are similar to foreground threads, except that background threads do not prevent the process from terminating. Once all foreground threads belonging to a process terminate, the common language runtime ends the process by calling Abort on any still active background thread.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service