microsoft / vs-threading

The Microsoft.VisualStudio.Threading is a xplat library that provides many threading and synchronization primitives used in Visual Studio and other applications.
Other
995 stars 147 forks source link

Support cancellation in AsyncBarrier #1329

Closed chenzhekl closed 5 months ago

chenzhekl commented 5 months ago

Is your feature request related to a problem? Please describe.

I want to have AsyncBarrier to support cancellation in SignalAndAwait, such that I can free those async functions from awaiting the barrier to finish.

Describe the solution you'd like

Maybe we can have SignalAndAwait accept an CancellationToken as its argument.

Describe alternatives you've considered

None

Additional context

None

AArnott commented 5 months ago

I'm not sure whether we'll deliver this yet. But in the meantime you can tack on .WithCancellation(ct) on the SignalAndWait call to achieve the same effect that we would probably deliver.

chenzhekl commented 5 months ago

Thanks! @AArnott . .WithCancellation(ct) works perfect for me as a workaround.