From 8bcb2c50415cdf2930762117255115cafce904b7 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Thu, 11 Jan 2018 10:05:21 +0100 Subject: [PATCH] Remember the suspend reason to detect changes there. Refers to #2 --- ATXTray/AutoTxTray.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ATXTray/AutoTxTray.cs b/ATXTray/AutoTxTray.cs index 5b3399b..a893d01 100644 --- a/ATXTray/AutoTxTray.cs +++ b/ATXTray/AutoTxTray.cs @@ -22,6 +22,7 @@ namespace ATXTray private static bool _statusChanged = false; private static bool _svcRunning = false; private static bool _svcSuspended = true; + private static string _svcSuspendReason; private readonly NotifyIcon _notifyIcon = new NotifyIcon(); private readonly ContextMenuStrip _cmStrip = new ContextMenuStrip(); @@ -158,13 +159,17 @@ namespace ATXTray } private void UpdateSvcSuspended() { - if (_svcSuspended == _status.ServiceSuspended) + // first update the suspend reason as this can possibly change even if the service + // never leaves the suspended state and we should still display the correct reason: + if (_svcSuspendReason == _status.LimitReason && + _svcSuspended == _status.ServiceSuspended) return; _statusChanged = true; _svcSuspended = _status.ServiceSuspended; + _svcSuspendReason = _status.LimitReason; if (_svcSuspended) { - _miSvcSuspended.Text = @"Service suspended, reason: " + _status.LimitReason; + _miSvcSuspended.Text = @"Service suspended, reason: " + _svcSuspendReason; _miSvcSuspended.BackColor = Color.LightYellow; /* _notifyIcon.ShowBalloonTip(500, "AutoTx Monitor", -- GitLab