Skip to content
Snippets Groups Projects
Commit 7dda7b63 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Reduce number of global variables.

Refers to #2
parent ff75fc1b
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,6 @@ namespace ATxTray ...@@ -24,7 +24,6 @@ namespace ATxTray
private const string AppTitle = "AutoTx Tray Monitor"; private const string AppTitle = "AutoTx Tray Monitor";
private static readonly Timer AppTimer = new Timer(1000); private static readonly Timer AppTimer = new Timer(1000);
private static bool _terminate = false;
private static string _statusFile; private static string _statusFile;
private static string _submitPath; private static string _submitPath;
...@@ -104,9 +103,10 @@ namespace ATxTray ...@@ -104,9 +103,10 @@ namespace ATxTray
Log.Error(msg); Log.Error(msg);
_notifyIcon.ShowBalloonTip(5000, AppTitle, msg, ToolTipIcon.Error); _notifyIcon.ShowBalloonTip(5000, AppTitle, msg, ToolTipIcon.Error);
// we cannot terminate the message loop (Application.Run()) while the constructor // we cannot terminate the message loop (Application.Run()) while the constructor
// is being run as it is not active yet - therefore we simply remember that we want // is being run as it is not active yet - therefore we set the _status object to
// to exit and evaluate this in the "Elapsed" handler: // null which will terminate the application during the next "Elapsed" event:
_terminate = true; _status = null;
// suspend the thread for 5s to make sure the balloon tip is shown for a while:
System.Threading.Thread.Sleep(5000); System.Threading.Thread.Sleep(5000);
} }
...@@ -192,7 +192,7 @@ namespace ATxTray ...@@ -192,7 +192,7 @@ namespace ATxTray
} }
private void AppTimerElapsed(object sender, ElapsedEventArgs e) { private void AppTimerElapsed(object sender, ElapsedEventArgs e) {
if (_terminate) { if (_status == null) {
AutoTxTrayExit(); AutoTxTrayExit();
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment