Structured concurrency groups for disposable resources #531
timcassell
started this conversation in
Show and tell
Replies: 1 comment
-
|
In v3.5.0, this is much simpler by just passing a cleanup delegate to the promise group. var promiseGroup = PromiseAllGroup<AsyncSemaphore.Scope>
.New(cancelationToken, out var groupCancelationToken, scope => scope.dispose());var promiseGroup = PromiseRaceGroup<AsyncSemaphore.Scope>
.New(cancelationToken, out var groupCancelationToken, scope => scope.dispose()); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Structured concurrency groups are super powerful for loading resources concurrently and canceling operations if an exception occurs, but they lack the native ability to dispose successfully loaded resources when an exception or cancelation occurs. I have implemented here 2 types that wrap the built-in structured concurrency groups to support this behavior for merge and race scenarios.
PromiseAllDisposableGroup
PromiseRaceDisposableGroup
An example usage for such types is to wait on multiple
AsyncSemaphoreinstances.Beta Was this translation helpful? Give feedback.
All reactions