示例#1
0
 public static void ExitApp()
 {
     if (!AlreadyClosed)
     {
         AlreadyClosed = true;
         if (Connection != null)
         {
             Connection.SendDisconnect();
         }
         LoginForm.Close();
         AppForm.Close();
         Application.Exit();
         //Environment.Exit(0);
     }
 }
示例#2
0
 public MyApplicationContext()
 {
     notifyIcon = new NotifyIcon()
     {
         ContextMenuStrip = new ContextMenuStrip {
             Text = "Open Form"
         },
         Text    = "Application",
         Visible = true,
         Icon    = new Icon("icon.ico")
     };
     appForm = new AppForm();
     notifyIcon.DoubleClick += (o, e) =>
     {
         appForm.Show();
     };
     RestartRequested += (o, e) =>
     {
         appForm?.Close();      //Close() will dispose the form as well.
         notifyIcon?.Dispose();
     };
     BackgroundWork();
 }