diff --git a/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs b/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs index 189e5f75..0606f326 100644 --- a/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs +++ b/windows/TweetDuck/Browser/Notification/FormNotificationTweet.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; +using TweetDuck.Controls; using TweetDuck.Management; using TweetDuck.Utils; using TweetLib.Browser.Interfaces; @@ -53,12 +54,12 @@ protected override bool CanDragWindow { } } - private void WindowsSessionManager_LockStateChanged(object? sender, EventArgs e) { - if (WindowsSessionManager.IsLocked) { - PauseNotification(NotificationPauseReason.WindowsSessionLocked); + private void WindowsSessionManager_LockStateChanged(object? sender, bool isLocked) { + if (isLocked) { + this.InvokeAsyncSafe(() => PauseNotification(NotificationPauseReason.WindowsSessionLocked)); } else { - ResumeNotification(NotificationPauseReason.WindowsSessionLocked); + this.InvokeAsyncSafe(() => ResumeNotification(NotificationPauseReason.WindowsSessionLocked)); } } diff --git a/windows/TweetDuck/Management/WindowsSessionManager.cs b/windows/TweetDuck/Management/WindowsSessionManager.cs index 2272fb6e..b7bee8d0 100644 --- a/windows/TweetDuck/Management/WindowsSessionManager.cs +++ b/windows/TweetDuck/Management/WindowsSessionManager.cs @@ -4,8 +4,7 @@ namespace TweetDuck.Management { static class WindowsSessionManager { - public static bool IsLocked { get; private set; } = false; - public static event EventHandler? LockStateChanged; + public static event EventHandler<bool>? LockStateChanged; public static void Register() { Win.Application.ApplicationExit += OnApplicationExit; @@ -27,8 +26,7 @@ private static void OnSessionSwitch(object? sender, SessionSwitchEventArgs e) { } private static void SetLocked(bool newState) { - IsLocked = newState; - LockStateChanged?.Invoke(null, EventArgs.Empty); + LockStateChanged?.Invoke(null, newState); } } }