private void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e) { if (_isScheduleMode) { bool allDownloaded = true; foreach (var thread in _threadsMap) { if (ThreadStatuses.GetThreadStatusTypeByStatus(thread.Value.Status) == ThreadStatusType.Failed) { thread.Value.StartThread(); allDownloaded = false; } } if (allDownloaded) { _time.Enabled = false; MessageBox.Show(@"Заявки скопированы"); MessageBox.Show(@"Все заявки скопированы. Дата/Время:" + DateTime.Now); } } if (_isAutoMode) { foreach (var thread in _threadsMap) { if (ThreadStatuses.GetThreadStatusTypeByStatus(thread.Value.Status) == ThreadStatusType.Failed) { thread.Value.StartThread(); } } } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { foreach (var thread in _threadsMap) { if (ThreadStatuses.GetThreadStatusTypeByStatus(thread.Value.Status) != ThreadStatusType.Failed) { thread.Value.SetThreadToStop(); } } }