Grain Support for IAsyncDisposable #8287
AlgorithmsAreCool
started this conversation in
General
Replies: 1 comment 3 replies
-
Grains support both IDisposable and IAsyncDisposable today and it works the way you want :) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Howdy!
I am doing some prototyping in Orleans and have been thrilled by all the improvements made over the past few years.
I am writing a stateless grain that will hold onto a connection to a database. I want to ensure the connection is disposed when the grain is deactivated. When I think about cleaning up resources in an object, my brain goes to IDisposable/IAsyncDisposable.
I am aware of the current way to implement this via
OnDeactivateAsync
, but what are your thoughts about also supporting IAsyncDisposable to be more idiomatic to the rest of .NET? I do have some concerns confusion about offering multiple ways to do something in the framework, but I think it could ease onboarding of new devs.A few other thoughts
IAsyncDisposable.DisposeAsync()
would be called after the call toOnDeactivateAsync
.OnDeactivateAsync
should stay for back compat as well as advanced use cases whereDeactivationReason
is needed.IDisposable
because of potential issues with making async calls inside of it.Beta Was this translation helpful? Give feedback.
All reactions