private void SendStatus(BatchFinderStatus status, string message) { BatchFinderStatusEventArgs e = new BatchFinderStatusEventArgs(); e.Status = status; e.Message = message; if (StatusChange != null) { StatusChange(this, e); } }
void Finder_StatusChange(object sender, BatchFinderStatusEventArgs e) { Invoke((MethodInvoker) delegate { lblMessage.Text = e.Message; switch (e.Status) { case BatchFinderStatus.Complete: { lblMessage.ForeColor = Color.Green; pbConnecting.Visible = false; DialogResult Ans = MessageBox.Show("Открыть сохраненный отчет?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Ans == DialogResult.No) { return; } string tmpMsg = CommonFunctions.OpenFile(ReportName); if (tmpMsg != string.Empty) { lblMessage.ForeColor = Color.Red; lblMessage.Text = tmpMsg; } }; break; case BatchFinderStatus.Working: { if (!pbConnecting.Visible) { pbConnecting.Visible = true; } lblMessage.ForeColor = Color.Blue; }; break; case BatchFinderStatus.Error: { lblMessage.ForeColor = Color.Red; pbConnecting.Visible = false; }; break; } }); }