Skip to content

erdtsieck/GuardedDisposables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GuardedDisposable

Since IDisposables are usually used in an using block, they create a try-finally which might swallow an exception if the IDisposable's implementation throws an Exception in the Dispose method. GuardedDisposables ensures those Exceptions will not get lost.

Usage

try
{
    using (var guardedDisposable = new ThirdPartyDisposable().Guard())
    {
        guardedDisposable.Execute(d => d.Foo());
    }
}
catch (GuardedDisposableException guardedDisposableException)
{
    HandleExeption(guardedDisposableException.ExecutionException);
    HandleExeption(guardedDisposableException.DisposeException);
}

About

GuardedDisposables ensures IDisposable Exceptions will not get lost.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages