diff --git a/docs/standard/garbage-collection/implementing-disposeasync.md b/docs/standard/garbage-collection/implementing-disposeasync.md index d750de5cf2a98..c309de1f2b1e2 100644 --- a/docs/standard/garbage-collection/implementing-disposeasync.md +++ b/docs/standard/garbage-collection/implementing-disposeasync.md @@ -42,19 +42,13 @@ The `public` parameterless `DisposeAsync()` method is called implicitly in an `a public async ValueTask DisposeAsync() { // Perform async cleanup. - await DisposeAsyncCore(); - - // Dispose of unmanaged resources. - Dispose(false); + await DisposeAsyncCore().ConfigureAwait(false); // Suppress finalization. GC.SuppressFinalize(this); } ``` -> [!NOTE] -> One primary difference in the async dispose pattern compared to the dispose pattern, is that the call from to the `Dispose(bool)` overload method is given `false` as an argument. When implementing the method, however, `true` is passed instead. This helps ensure functional equivalence with the synchronous dispose pattern, and further ensures that finalizer code paths still get invoked. In other words, the `DisposeAsyncCore()` method will dispose of managed resources asynchronously, so you don't want to dispose of them synchronously as well. Therefore, call `Dispose(false)` instead of `Dispose(true)`. - ### The `DisposeAsyncCore` method The `DisposeAsyncCore()` method is intended to perform the asynchronous cleanup of managed resources or for cascading calls to `DisposeAsync()`. It encapsulates the common asynchronous cleanup operations when a subclass inherits a base class that is an implementation of . The `DisposeAsyncCore()` method is `virtual` so that derived classes can define custom cleanup in their overrides. diff --git a/docs/standard/garbage-collection/snippets/dispose-async/ExampleConjunctiveDisposable.cs b/docs/standard/garbage-collection/snippets/dispose-async/ExampleConjunctiveDisposable.cs index 0dfbe02bf1966..2a7966849a697 100644 --- a/docs/standard/garbage-collection/snippets/dispose-async/ExampleConjunctiveDisposable.cs +++ b/docs/standard/garbage-collection/snippets/dispose-async/ExampleConjunctiveDisposable.cs @@ -13,7 +13,6 @@ public async ValueTask DisposeAsync() { await DisposeAsyncCore().ConfigureAwait(false); - Dispose(disposing: false); GC.SuppressFinalize(this); }