コード例 #1
0
        private void DoClose()
        {
            _isClosing = true;
            Properties.Settings.Default.Save();

            List <string> listOfKeys = new List <string>();

            foreach (string _k in TimersList.Keys)
            {
                listOfKeys.Add(_k);
            }
            foreach (string name in listOfKeys)
            {
                SingleTimerLib.SingleTimer _t = TimersList[name];
                _t.PropertyChanged    -= SingleTimer_PropertyChanged;
                _t.SingleTimerChanged -= SingleTimer_SingleTimerChanged;
                _t.TimerReset         -= SingleTimer_OnTimerReset;
                _t.StopTimer();
                TimersList.Remove(_t.CanonicalName);
                TimerName2RowIndexDictionary.Remove(_t.CanonicalName);
                DebugPrint(string.Format("Timer {0} is being is about to be disposed!", _t.Name));
                _t.Dispose();
            }

            WriteDataToXml();

            listOfKeys.Clear();
            listOfKeys = null;

            Hide();
            jobTimersIcon.Visible = false;
            FormClosing          -= JobTimerForm_FormClosing;
            Close();
            Application.Exit();
        }
コード例 #2
0
 private void TreadSafeDeleteDataGridViewRows()
 {
     if (timersDataGridView.InvokeRequired)
     {
         timersDataGridView.Invoke(new Action(TreadSafeDeleteDataGridViewRows));
         return;
     }
     foreach (DataGridViewRow _dr in timersDataGridView.SelectedRows)
     {
         string name = timersDataGridView.CurrentRow.TimerCanonicalName();
         SingleTimerLib.SingleTimer _t = TimersList[name];
         _t.SingleTimerChanged -= SingleTimer_SingleTimerChanged;
         _t.PropertyChanged    -= SingleTimer_PropertyChanged;
         _t.TimerReset         -= SingleTimer_OnTimerReset;
         _t.StopTimer();
         Debug.Assert(_t.CanonicalName == Timers.Rows[_t.RowIndex].TimerCanonicalName());
         Timers.Rows.RemoveAt(_t.RowIndex);
         Timers.AcceptChanges();
         ThreadSafeUpdateDataGridView();
         TimerName2RowIndexDictionary.Remove(name);
         TimersList.Remove(name);
         _t.Dispose();
     }
 }