/// <summary> /// Will close system and update files /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void Update(object sender, EventArgs e) { hasUpdate = false; //notifyicon.Icon = System.Drawing.Icon.FromHandle(Properties.Resources.update_16.GetHicon()); notifyicon.Icon = System.Drawing.Icon.FromHandle(UpdateImageRefresh.GetHicon()); contextmenu.Items["Stop"].Enabled = true; contextmenu.Items["Start"].Enabled = true; contextmenu.Items["Check"].Visible = true; contextmenu.Items["Update"].Visible = false; notifyicon.ShowBalloonTip(1000, "CDS Update Server", "System will now update and restart.", ToolTipIcon.Info); System.Threading.Thread.Sleep(1000 * 5); //Werner: Testing only Update Service will restart application Application.Restart(); }
/// <summary> /// Sends command to update service to check for updates /// </summary> /// <remarks> /// If we want the service to send feedback we will need to implement SingleInstance Application /// http://stackoverflow.com/questions/3793997/pass-arguments-to-running-application /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> static void CheckForUpdates(object sender, EventArgs e) { try { servicecontroller.ExecuteCommand(128); //notifyicon.Icon = System.Drawing.Icon.FromHandle(Properties.Resources.update_16.GetHicon()); notifyicon.Icon = System.Drawing.Icon.FromHandle(UpdateImageRefresh.GetHicon()); System.Threading.Thread.Sleep(1000 * 5); hasUpdate = true; notifyicon.Icon = System.Drawing.Icon.FromHandle(UpdateImageNew.GetHicon()); contextmenu.Items["Stop"].Enabled = false; contextmenu.Items["Start"].Enabled = false; contextmenu.Items["Check"].Visible = false; contextmenu.Items["Update"].Visible = true; } catch (Exception ex) { notifyicon.ShowBalloonTip(1000, "CDS Update Server", "An error occurred trying to execute this operation." + ex.ToString(), ToolTipIcon.Info); } }