What the the practice for cleaning up cancelled CancellationTokenSource objects? #602
Replies: 1 comment
|
My understanding is that a cancelled UniTask is already in a terminal state, so there isn't usually an additional cleanup step required for the UniTask itself. The part that typically needs cleanup is the cts.Cancel();
cts.Dispose();(and create a new instance if you need to reuse the workflow). If the token comes from something like One thing I'm not completely sure about is whether the entries you're seeing in UniTaskTracker are actually still alive, or if the tracker is simply showing completed/cancelled tasks for diagnostic purposes. If they're in the I'd be more concerned if tasks remain Could you share whether those entries stay as |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Can someone tell me what the correct practice is for cleaning up a UniTask that has been cancelled via a CancellationTokenSource? In the UniTaskViewer panel I am seeing some dangling tasks with the "Cancelled" status so I want to know what needs to be done to make sure these things are cleaned up correctly?
I have seen exampled that have a Cancel, Dispose, New' idiom but that can't always be done if something else is cancelling the CTS such as the GetCancellationTokenOnDestroy or something that is cancelled by someone else.
All reactions