public void OnUpdateProgress(object sender, OutputEventArgs e) { if (_dicTabPages.ContainsKey(e.strProName)) { _dicTabPages[e.strProName].updateProgress(e); } }
/// /// <summary> /// Updates progress of the progress bar and status of a given target. /// Uses SafeBeginInvoke to test whether it is safe for the two threads /// (the Main Thread and the TargetUpload Thread) to communicate/pass information. /// Because of the nature of SafeBeginInvoke, it is not always safe to communicate /// between the two Threads. Therefore, not all calls are successful to OnUpdateProgress(). /// Because calls to OnUpdateProgress() are put into a queue, when the upload Processes and /// Threads are terminated the progress bar and status field continue to update for a small /// amount of time. _lstStopList and _stopAll are used to flag that the upload process /// has been stopped, so any OnUpdateProgress() calls left in the queue with not effect the display/status /// of the List View screen. /// </summary> /// <param name="e">Contains the target address, progress, and speed of an upload</param> public void updateProgress(OutputEventArgs e) { this.targetList.SafeBeginInvoke(new Action(() => //Tests whether is it safe to communicate { if (targetList.Items.ContainsKey(e.strTarget) == true) //Checks if ListView item exists for target IP { if ((_lstStopList.Contains(e.strTarget)) || (_stopAll == true)) //Checks if IP has been flagged to stop { if (_lstStopList.Contains(e.strTarget)) { targetList.Items[e.strTarget].SubItems[3].Text = "Stopped"; //Sets target's status to 'Stopped' targetList.Items[e.strTarget].SubItems[4].Text = ""; } else { updateStatus("", "Stopped"); //Sets all targets to 'Stopped' } } else { int percentageDone = (int)e.percent; int row = targetList.Items[e.strTarget].Index; //Finds row of target ProgressBar pb = targetList.GetEmbeddedControl(e.strTarget) as ProgressBar; //Fetches progress bar if (percentageDone <= 100) { pb.Value = percentageDone; } targetList.Items[e.strTarget].SubItems[2].Text = percentageDone.ToString() + "%"; targetList.Items[e.strTarget].SubItems[3].Text = "Running"; targetList.Items[e.strTarget].SubItems[4].Text = e.strSpeed; if (percentageDone >= 100) { targetList.Items[e.strTarget].SubItems[3].Text = "Done"; targetList.Items[e.strTarget].SubItems[4].Text = ""; } } } })); }
/// /// <summary> /// Updates progress of the progress bar and status of a given target. /// Uses SafeBeginInvoke to test whether it is safe for the two threads /// (the Main Thread and the TargetUpload Thread) to communicate/pass information. /// Because of the nature of SafeBeginInvoke, it is not always safe to communicate /// between the two Threads. Therefore, not all calls are successful to OnUpdateProgress(). /// Because calls to OnUpdateProgress() are put into a queue, when the upload Processes and /// Threads are terminated the progress bar and status field continue to update for a small /// amount of time. _lstStopList and _stopAll are used to flag that the upload process /// has been stopped, so any OnUpdateProgress() calls left in the queue with not effect the display/status /// of the List View screen. /// </summary> /// <param name="e">Contains the target address, progress, and speed of an upload</param> public void updateProgress(OutputEventArgs e) { this.targetList.SafeBeginInvoke(new Action(() => //Tests whether is it safe to communicate { if(targetList.Items.ContainsKey(e.strTarget) == true) //Checks if ListView item exists for target IP { if((_lstStopList.Contains(e.strTarget)) || (_stopAll == true)) //Checks if IP has been flagged to stop { if(_lstStopList.Contains(e.strTarget)) { targetList.Items[e.strTarget].SubItems[3].Text = "Stopped"; //Sets target's status to 'Stopped' targetList.Items[e.strTarget].SubItems[4].Text = ""; } else { updateStatus("", "Stopped"); //Sets all targets to 'Stopped' } } else { int percentageDone = (int)e.percent; int row = targetList.Items[e.strTarget].Index; //Finds row of target ProgressBar pb = targetList.GetEmbeddedControl(e.strTarget) as ProgressBar; //Fetches progress bar if(percentageDone <= 100) { pb.Value = percentageDone; } targetList.Items[e.strTarget].SubItems[2].Text = percentageDone.ToString() + "%"; targetList.Items[e.strTarget].SubItems[3].Text = "Running"; targetList.Items[e.strTarget].SubItems[4].Text = e.strSpeed; if(percentageDone >= 100) { targetList.Items[e.strTarget].SubItems[3].Text = "Done"; targetList.Items[e.strTarget].SubItems[4].Text = ""; } } } })); }