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(); } } }
private void UpdateStatusWithAdditionalInfo(ThreadStatus newStatus, string additionalInfo) { Status = newStatus; string newText = GetMessageByStatus(Status, additionalInfo); Color newColor = ThreadStatuses.GetColorByStatus(Status); if (_textBox.InvokeRequired) _textBox.Invoke(new Action<string, Color>((text, color) => { _textBox.Text = text; _textBox.BackColor = color; }), newText, newColor); else { _textBox.Text = newText; _textBox.BackColor = newColor; } }
private string GetMessageByStatus(ThreadStatus status, string additionalInfo) { return ThreadStatuses.GetMessageByStatus(status, additionalInfo); }