public MainForm() { _activityMonitor = MonitorService.GetInstance().GetActivityMonitor(); InitializeComponent(); CanClose = false; if (_activityMonitor.Started()) { startToolStripMenuItem.Enabled = false; stopToolStripMenuItem.Enabled = true; } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.WindowsShutDown) { CanClose = true; } if (!CanClose) { Visible = false; ShowInTaskbar = false; timerRefreshLogs.Enabled = false; } if (CanClose && _activityMonitor.Started()) { Stop(); } e.Cancel = !CanClose; }