Task.Abort() #115614
-
I am using Tasks and IAsyncEnumerables for pretty much everything, so i can't abort the task without passing a CancellationTokenSource into every part of my code. at the moment my task just stays in memory forever waiting for a TaskCompletionSource i know will never be set, but i have a lot of those, so cancelling all of them wouldn't be the best solution. an Abort or at least a TryAbort function would make this way easier. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
See #115547. Thread aborts (and by extension task aborts) will never be supported again in dotnet. They are horribly unsafe and a crutch for bad code. |
Beta Was this translation helpful? Give feedback.
-
As a side answer - note that often what happens for this sort of code is you'll end up with a "root" token source and then link other token sources, for supporting things like mass cancellation (eg, used for graceful shutdown when you close an application). |
Beta Was this translation helpful? Give feedback.
See #115547. Thread aborts (and by extension task aborts) will never be supported again in dotnet. They are horribly unsafe and a crutch for bad code.