Skip to content

Commit

Permalink
NotifyIcon disposal - second attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Jul 24, 2023
1 parent b0334b7 commit d186126
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Bloxstrap/UI/NotifyIconWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class NotifyIconWrapper : IDisposable
{
// lol who needs properly structured mvvm and xaml when you have the absolute catastrophe that this is

bool _disposed = false;
private bool _disposing = false;

private readonly System.Windows.Forms.NotifyIcon _notifyIcon;
private MenuContainer? _menuContainer;
Expand Down Expand Up @@ -128,15 +128,16 @@ public void ShowAlert(string caption, string message, int duration, EventHandler

public void Dispose()
{
if (_disposed)
if (_disposing)
return;

_disposing = true;

App.Logger.WriteLine($"[NotifyIconWrapper::Dispose] Disposing NotifyIcon");

_menuContainer?.Dispatcher.Invoke(_menuContainer.Close);
_notifyIcon?.Dispose();

_disposed = true;

GC.SuppressFinalize(this);
}
Expand Down

0 comments on commit d186126

Please sign in to comment.