3 ms·
Relevant to the topic, annoyingly, you still can't cancel a task without a ton of garbage.
by jayd16 6y ago
Relevant to the topic, annoyingly, you still can't cancel a task without a ton of garbage.
- Const-me 6y agoYou can easily forget pending tasks. That’s a single line of code like this: task.ContinueWith( t => { }, TaskContinuationOptions.OnlyOnFaulted ); However, graceful cancellation is indeed hard. Doable in .NET but not easy, you gonna need to manually pass these cancellation tokens all the way down. Do you have an example of a language/runtime/etc where the cancellation's easy? It's easy to kill processes from the outside, but even for threads it's borderline impossible without horrible side effects.
- jayd16 6y agoI don't. I don't use Rust but I'm quite sad I can't use this system in C# without paying for a stacktrace/exception. Cancellation tokens sure...but many libraries will still throw the cancellation exception.