Example #1
0
        internal static void Main()
        {
            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            if (Medo.Application.Args.Current.ContainsKey("Interactive"))
            {
                Tray.Show();
                ServiceThread.Start();
                Tray.SetStatusToRunningInteractive();
                Application.Run();
                ServiceThread.Stop();
                Tray.Hide();
                Environment.Exit(0);
            }
            else if (Medo.Application.Args.Current.ContainsKey("Install"))
            {
                ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location });
                System.Environment.Exit(0);
            }
            else if (Medo.Application.Args.Current.ContainsKey("Uninstall"))
            {
                try {
                    ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location });
                    System.Environment.Exit(0);
                } catch (System.Configuration.Install.InstallException) { //no service with that name
                    System.Environment.Exit(-1);
                }
            }
            else
            {
                if (Environment.UserInteractive)
                {
                    Tray.Show();
                    ServiceStatusThread.Start();
                    Application.Run();
                    ServiceStatusThread.Stop();
                    Tray.Hide();
                    Environment.Exit(0);
                }
                else
                {
                    ServiceBase.Run(new ServiceBase[] { AppService.Instance });
                }
            }
        }
Example #2
0
 protected override void OnStop()
 {
     ServiceThread.Stop();
 }
Example #3
0
 protected override void OnStart(string[] args)
 {
     ServiceThread.Start();
 }