Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.SlaveTrayIcon/Program.cs @ 5955

Last change on this file since 5955 was 5780, checked in by ascheibe, 14 years ago

#1233 worked on installer and slave

File size: 1.4 KB
RevLine 
[5314]1using System;
[5780]2using System.Diagnostics;
[5314]3using System.Windows.Forms;
[5599]4using HeuristicLab.Clients.Hive.SlaveCore.Views;
[5314]5
[5599]6namespace HeuristicLab.Clients.Hive.SlaveCore.SlaveTrayIcon {
[5314]7  static class Program {
8    /// <summary>
9    /// The main entry point for the application.
10    /// </summary>
11    [STAThread]
12    static void Main() {
[5780]13      KillOtherInstances();
14
[5314]15      Application.EnableVisualStyles();
16      Application.SetCompatibleTextRenderingDefault(false);
17      MainWindow mw = new MainWindow();
18      mw.MinimizeToTray();
19      mw.Content = new SlaveItem();
20
21      Application.Run();
22    }
[5780]23
24    /// <summary>
25    /// kill all other slave tray icons, we only want 1 running at a time
26    /// (and if a newer version is installed the older one should be killed)
27    /// </summary>
28    private static void KillOtherInstances() {
29      Process curProc = Process.GetCurrentProcess();
30
31      try {
32        Process[] procs = Process.GetProcessesByName(curProc.ProcessName);
33        foreach (Process p in procs) {
34          if (p.Id != curProc.Id) {
35            p.Kill();
36          }
37        }
38      }
39      catch (InvalidOperationException) {
40      }
41      catch (Exception) {
42        MessageBox.Show("There is another instance of the Hive Slave tray icon running which can't be closed.", "HeuristicLab Hive Slave");
43      }
44    }
[5314]45  }
46}
Note: See TracBrowser for help on using the repository browser.