2 Commits

Author SHA1 Message Date
287c008117 Make sure icon gets removed 2021-12-20 14:01:48 -05:00
42301d5242 More startup/upgrade cleanup 2021-12-20 13:57:21 -05:00
2 changed files with 20 additions and 18 deletions

View File

@@ -36,6 +36,22 @@ namespace WorkIndicator
_dispatcher = Dispatcher.CurrentDispatcher; _dispatcher = Dispatcher.CurrentDispatcher;
// Create an isolation handle to see if we are already running
_isolationHandle = ApplicationIsolation.GetIsolationHandle();
// If there is another copy then pass it the command line and exit
if (_isolationHandle == null)
{
try
{
InterprocessMessageSender.SendMessage(Environment.CommandLine);
}
catch { }
Shutdown();
return;
}
// Initialize the command line listener // Initialize the command line listener
_commandLineListener = new InterprocessMessageListener(Assembly.GetEntryAssembly().GetName().Name); _commandLineListener = new InterprocessMessageListener(Assembly.GetEntryAssembly().GetName().Name);
_commandLineListener.MessageReceived += HandleCommandLine; _commandLineListener.MessageReceived += HandleCommandLine;
@@ -53,22 +69,6 @@ namespace WorkIndicator
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
// Create an isolation handle to see if we are already running
_isolationHandle = ApplicationIsolation.GetIsolationHandle();
// If there is another copy then pass it the command line and exit
if (_isolationHandle == null)
{
try
{
InterprocessMessageSender.SendMessage(Environment.CommandLine);
}
catch { }
_dispatcher.Invoke(Shutdown);
return;
}
// Set automatic start into the registry // Set automatic start into the registry
Current.SetStartWithWindows(Settings.Default.StartWithWindows); Current.SetStartWithWindows(Settings.Default.StartWithWindows);
@@ -89,10 +89,12 @@ namespace WorkIndicator
private void HandleUpdateStatus(UpdateCheck.UpdateStatus status, string message) private void HandleUpdateStatus(UpdateCheck.UpdateStatus status, string message)
{ {
if (status != UpdateCheck.UpdateStatus.Downloading) if (status != UpdateCheck.UpdateStatus.Installing)
return; return;
_dispatcher.Invoke(() => TrayIcon.ShowUpdateMessage(message)); _dispatcher.Invoke(() => TrayIcon.ShowUpdateMessage(message));
TrayIcon.Dispose();
} }
protected override void OnExit(ExitEventArgs e) protected override void OnExit(ExitEventArgs e)

View File

@@ -70,7 +70,7 @@ namespace WorkIndicator
public static void ShowUpdateMessage(string text) public static void ShowUpdateMessage(string text)
{ {
_trayIcon.ShowBalloonTip(250, Resources.ApplicationName, text, ToolTipIcon.None); _trayIcon.ShowBalloonTip(200, Resources.ApplicationName, text, ToolTipIcon.None);
} }
static void HandleContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e) static void HandleContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)