mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-11 09:49:22 +08:00
adding disposed pattern
This commit is contained in:
parent
e4e2586939
commit
bc22631340
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user