mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
implement the complete IDisposable pattern
This commit is contained in:
parent
874a785be4
commit
4005054500
1 changed files with 23 additions and 4 deletions
|
|
@ -83,12 +83,31 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
};
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Dispose managed resources
|
||||
if (context?.API != null)
|
||||
{
|
||||
context.API.VisibilityChanged -= OnVisibilityChanged;
|
||||
}
|
||||
}
|
||||
// Free unmanaged resources
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
~ThemeSelector()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (context != null && context.API != null)
|
||||
{
|
||||
context.API.VisibilityChanged -= OnVisibilityChanged;
|
||||
}
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue