-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support IAsyncDisposable #9960
Comments
Agreed - thanks for the suggestion! |
When we add support for |
@rynowak I was trying to figure out what was necessary to make this work and it seems like this would have to by made to return a task, which would bubble up to the point where we have to change public API's. Is that expected or do we have a way to call this asynchronously without changing a ton of API surface? |
It depends which public APIs there are. I think the renderer is declared as unstable. |
I suspect we wouldn't want to change the incoming code paths to become async, since they are right in the middle of rendering which aims to be as synchronous as possible.
It might be sufficient to chain onto the returned disposal promises either using |
Yeah, the real problem seems to start with Steve's suggestion sounds reasonable, though I'd have to poke around a bit deeper to understand the details. The other idea I've heard is @NTaylorMullen suggested that rather than modify existing API surface we could add new Async APIs and have both. Given that it's apparently a goal/requirement to keep Rendering sync I imagine that's not the preferred solution? |
Async disposable support for BlazorCurrently we only support disposing components synchronously. For disposable components there are several design decissions that we've made along the way:
All these behaviors happen synchronously, so that means that a render batch only finishes rendering after all the components have been disposed and there are no more renders to process. Supporting async disposal brings in several questions:
Overview of the design
|
Done in 763ccb2 |
Is your feature request related to a problem? Please describe.
I implement
IDisposable
in some components to interop with JS, to clean up resources on the JS end. Blazor callsDispose()
on my component as appropriate.However, this requires using
IJSInProcessRuntime
to get synchronous JS invocations.Describe the solution you'd like
If the component implements
IAsyncDisposable
, Blazor should call (await
)DisposeAsync
.The text was updated successfully, but these errors were encountered: