implement the complete IDisposable pattern

This commit is contained in:
Jeremy Wu 2025-01-18 21:16:04 +11:00 committed by GitHub
parent 874a785be4
commit 4005054500
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}
}
}