Home > Net >  Winform window with await more async complicated time-consuming query, closed form, how close the th
Winform window with await more async complicated time-consuming query, closed form, how close the th

Time:10-30

Winform with await async complicated time-consuming query, closed form, how close the thread?
If closed form, the thread is still running in the background, how can be closed

CodePudding user response:

Baidu, cancelTokenSource

CodePudding user response:

Await async is stuck in there, not only the end of the process in task manager,

CodePudding user response:

reference 1st floor wanghui0380 response: ,
baidu cancelTokenSource


CancelTokenSource, not really cancel

CodePudding user response:

WinForm main form is closed, the Application process will automatically exit, all threads within the process will be terminated (abort), it is the operating system the internal mechanisms, applications do not need to care about, we can't cancel a gracefully threads are run, unless thread internal code can receive at any time to terminate instructions and react accordingly (for example CancelTokenSource), but is related to resource operation (such as disk files, network session) may have a problem, for example, a background thread to the U disk copy the file, the program exits may file copy only half, improper handling will leave some of the garbage data,
  •  Tags:  
  • C#
  • Related