So my question is how to implement the undo / interrupt function in all (I mean ALL) thread workers in your application in the best and most elegant way?
It doesn’t matter if it is an HttpWebRequest, an I / O operation or a calculation. The user should be able to cancel each action / thread at any time.
Use .NET 4.0 Taskwith CancellationToken- this is a new universal cancellation system.
Task
CancellationToken
/ .
Threading - , ... , , . , ! , , , , :
, , , , , .. , , , , , ... , , . : .
, , . , , , .
, HttpWebRequest, / .
, , ! , , .
P.S., , Thread.IsBackground true, , .
Thread.IsBackground
true
, , . - static volatile bool , , .
static volatile bool
, , , . , , .
Thread.Abort() : .
Source: https://habr.com/ru/post/1746247/More articles:How to render .NET TableCell as TH instead of TD? - .netHow to register a marker interface so that it displays in Plones ZMI? - zopeASP.NET User Control Status - asp.netconditional operator in question C - cThe sequence of events when creating an ASP.NET page - eventsManipulating a thread from another thread - multithreadingHow to configure CommandTImeout parameter in DbFit for long queries? - .netEnable / disable network settings on Android - javaHow can I call model methods or properties from Django Admin? - propertiesInsert line break from target variable c - xmlAll Articles