You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
• Dispose(bool disposing) is called with true when the object is being disposed explicitly (by user code), and with false when called from a finalizer (to clean up unmanaged resources only).
• In the async dispose pattern, DisposeAsync() should call DisposeAsyncCore() to asynchronously release resources, then suppress finalization.
• There is no need to call Dispose(false) from DisposeAsync(), because:
• You are not in a finalizer.
• All resource cleanup should already be handled in DisposeAsyncCore().
The correct pattern for IAsyncDisposable is:
public async ValueTask DisposeAsync() { await DisposeAsyncCore().ConfigureAwait(false); GC.SuppressFinalize(this); }
Uh oh!
There was an error while loading. Please reload this page.
Type of issue
Typo
Description
• Dispose(bool disposing) is called with true when the object is being disposed explicitly (by user code), and with false when called from a finalizer (to clean up unmanaged resources only).
• In the async dispose pattern, DisposeAsync() should call DisposeAsyncCore() to asynchronously release resources, then suppress finalization.
• There is no need to call Dispose(false) from DisposeAsync(), because:
• You are not in a finalizer.
• All resource cleanup should already be handled in DisposeAsyncCore().
The correct pattern for IAsyncDisposable is:
public async ValueTask DisposeAsync() { await DisposeAsyncCore().ConfigureAwait(false); GC.SuppressFinalize(this); }
Page URL
https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-disposeasync
Content source URL
https://github.com/dotnet/docs/blob/main/docs/standard/garbage-collection/implementing-disposeasync.md
Document Version Independent Id
d72276e1-9059-815f-dc14-a03a7544ab87
Platform Id
cc69165e-7f9b-8c59-0b79-2ba09c791e8e
Article author
@IEvangelist
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: