Support IAsyncDisposable
See original GitHub issueIs 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 calls Dispose()
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
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:22
- Comments:8 (8 by maintainers)
Top Results From Across the Web
IAsyncDisposable Interface (System)
The IAsyncDisposable.DisposeAsync method of this interface returns a ValueTask that represents the asynchronous dispose operation.
Read more >Implementing both IDisposable and IAsyncDisposable
Proxy might not support IAsyncDisposable . Failing to cast object to IDisposable will present hard to catch bugs in your app.
Read more >How to work with IAsyncDisposable in .NET 6
Take advantage of the IAsyncDisposable interface to dispose of objects in a non-blocking way and make your .NET applications more efficient.
Read more >How to properly use IAsyncDisposable in C#8
How to implement IAsyncDisposable. Basically, the simplest way to implement IAsyncDisposable is the following: public class Example : ...
Read more >ASP.NET Core in .NET 6 - Support for IAsyncDisposable ...
In this post, I want to have a look at the Support for IAsyncDisposable in MVC. The IAsyncDisposable is a thing since .NET...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Done in https://github.com/dotnet/aspnetcore/commit/763ccb21b53f281fdb0ae4c894d9040b7b6223a3
Async disposable support for Blazor
Currently 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