// Handle progress report event from communication thread private void OnComNotification(object sender, NoticeArg e) { // Cross thread if (frmMainRef.InvokeRequired) { frmMainRef.Invoke(new Action <object, NoticeArg>(OnComNotification), new object[] { sender, e }); return; } // Update status string if (e.ThreadID < listStatus.Count) { // Add message to list status string status = "[Thread " + e.ThreadID.ToString() + " - Loop " + e.Loop.ToString() + " ] " + e.Message + " \r\n"; listStatus[e.ThreadID] += status; // Display all status in text box txtStatus.Text = ""; for (int i = 0; i < listStatus.Count; i++) { txtStatus.Text += listStatus[i]; txtStatus.Text += "\n"; } } }
// Report Progress private void ReportProgress(string Message) { // Create new notification argument NoticeArg Arg = new NoticeArg(ThreadID, round, Message); // Raise Msg Incoming event var handler = EventHappned; if (handler != null) { handler(this, Arg); } }
// Handle progress report event from communication thread private void OnComNotification(object sender, NoticeArg e) { // Cross thread if (frmMainRef.InvokeRequired) { frmMainRef.Invoke(new Action<object, NoticeArg>(OnComNotification), new object[] { sender, e}); return; } // Update status string if (e.ThreadID < listStatus.Count) { // Add message to list status string status = "[Thread " + e.ThreadID.ToString() + " - Loop " + e.Loop.ToString() + " ] " + e.Message + " \r\n"; listStatus[e.ThreadID] += status; // Display all status in text box txtStatus.Text = ""; for (int i = 0; i < listStatus.Count; i++) { txtStatus.Text += listStatus[i]; txtStatus.Text += "\n"; } } }