Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
fix(core): fix event handler leak
Browse files Browse the repository at this point in the history
  • Loading branch information
mika-f committed Jul 10, 2019
1 parent 1ba03e0 commit 1e9ddf7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/Robock/Models/Desktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Desktop(Screen screen, int index)
{
Query = new EventQuery($@"SELECT * FROM RegistryValueChangeEvent WHERE Hive = 'HKEY_USERS' AND KeyPath = '{identity.User.Value}\\Control Panel\\Desktop' AND ValueName = 'Wallpaper'")
};
_watcher.EventArrived += (sender, e) => GetCurrentWallpaper();
_watcher.EventArrived += OnEventArrived;
_watcher.Start();

GetCurrentWallpaper();
Expand All @@ -67,11 +67,17 @@ public void Dispose()
}
finally
{
_watcher.EventArrived -= OnEventArrived;
_watcher.Stop();
_watcher.Dispose();
}
}

private void OnEventArrived(object sender, EventArrivedEventArgs _)
{
GetCurrentWallpaper();
}

public async Task Handshake()
{
_process = Process.Start("Robock.Background.exe", $"{_uuid}");
Expand Down

0 comments on commit 1e9ddf7

Please sign in to comment.