-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hi, @kekyo , I'm looking through your code,
| ct.Register(() => tcs.TrySetCanceled()); |
here it registered a cancel callback, but it never dispose even when lock is acquired, ct would hold on to all the tcs until it's cancelled. In my case I create one CancellationTokenSource, only Cancel when the app is closed, if any race condition happen it would add a registration to the linked list inside cts
maybe add something like this:
if (ct != default)
{
var registration = ct.Register(() => tcs.TrySetCanceled());
tcs.Task.ContinueWith(_ => registration.Dispose(), TaskContinuationOptions.ExecuteSynchronously); // dispose registration after task completion
}I see it was done in AsyncEx lib
kekyo
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working