-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Watcher Race Conditions & Ensured Application Hotkey Refreshes …
…System Tray (#124) * Tried ensuring the audio drop down takes into account different resolutions. * Fixed race conditions occurring from FileSystemWatcher for the application UI and system tray. * Ensured system tray gets refreshed once hotkeys are set through the application UI.
- Loading branch information
Showing
3 changed files
with
59 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
public static class DisplayProfileWatcher | ||
{ | ||
private static FileSystemWatcher fileSystemWatcher; | ||
private static readonly object LockObject = new(); | ||
|
||
public static event FileSystemEventHandler ProfileChanged; | ||
|
||
public static void Initialize(string directoryPath) | ||
{ | ||
if (fileSystemWatcher != null) return; | ||
|
||
lock (LockObject) | ||
{ | ||
if (fileSystemWatcher == null) | ||
{ | ||
fileSystemWatcher = new FileSystemWatcher(directoryPath) | ||
{ | ||
NotifyFilter = NotifyFilters.FileName, | ||
EnableRaisingEvents = true | ||
}; | ||
|
||
fileSystemWatcher.Created += OnProfileChanged; | ||
fileSystemWatcher.Deleted += OnProfileChanged; | ||
fileSystemWatcher.Renamed += OnProfileChanged; | ||
} | ||
} | ||
} | ||
|
||
private static void OnProfileChanged(object sender, FileSystemEventArgs e) | ||
{ | ||
ProfileChanged?.Invoke(sender, e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters