adding disposed pattern

This commit is contained in:
Clint Rutkas 2020-11-11 13:18:15 -08:00
parent e4e2586939
commit bc22631340

View File

@ -13,11 +13,10 @@ using ImageResizer.Views;
namespace ImageResizer
{
#pragma warning disable CA1001 // Types that own disposable fields should be disposable
public partial class App : Application
#pragma warning restore CA1001 // Types that own disposable fields should be disposable
public partial class App : Application, IDisposable
{
private ThemeManager _themeManager;
private bool _isDisposed;
static App()
{
@ -45,5 +44,27 @@ namespace ImageResizer
_ = NativeMethods.SendInput(1, inputs, NativeMethods.INPUT.Size);
NativeMethods.SetForegroundWindow(hWnd);
}
protected virtual void Dispose(bool disposing)
{
if (!_isDisposed)
{
if (disposing)
{
_themeManager.Dispose();
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
_isDisposed = true;
}
}
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}