Skip to content

Commit

Permalink
dispose service before throw
Browse files Browse the repository at this point in the history
  • Loading branch information
maryamariyan committed Nov 24, 2020
1 parent 9d9c9ae commit 3931f61
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ internal object CaptureDisposable(object service)
{
if (_disposed)
{
if (_disposables != null)
if (service is IDisposable disposable)
{
// cleanup disposable just in case still has items before throwing
foreach (IDisposable disposable in _disposables)
{
disposable.Dispose();
}
disposable.Dispose();
}
else
{
((IAsyncDisposable)service).DisposeAsync().AsTask().Wait();
}
ThrowHelper.ThrowObjectDisposedException();
}
Expand Down

0 comments on commit 3931f61

Please sign in to comment.