Comment by estimator7292
4 hours ago
Cancelling a token doesn't immediately abort the underlying Task. It is up to the implementation of that task to poll the token and actively decide when to abort.
In your example, you'd design your delete task such that if you want it to be cancelable, it can only be canceled before data is modified. You simply don't abort in the middle of a database transaction.
Moreover, because of the way cancellation tokens work, you can't abort blocking function calls unless you also pass the token along. There just isn't a mechanism that can interrupt a long IO operation or whatever unless you explicitly go to the effort to make that happen.
A cancellation token is more of a "pretty please stop what you're doing when you feel like it" concept than Thread.Abort().
No comments yet
Contribute on Hacker News ↗