BackgroundWorker - Form. , . Work BackgroundWorker , null .
BackgroundWorker, ProgressReporting, (BackgroundWorker bgWorker, params object [] otherParams) , :
if( bgWorker != null && bgWorker.WorkerReportsProgress )
{
bgWorker.ReportProgress( percentage );
}
... CancellationPending.
Forms . bgWorker.DoWork += new DoWorkEventHandler( startBgWorker );, Worker.Work, bgWorker .
, bgWorker.RunWorkerAsync.
bgWorker.CancelAsync, , CancellationPending.
RunWorkerCompleted, , . , , .
Work, , Forms ComponentModel.
And, of course, you implement the progresschanged event without having to reinvent the wheel on it. ProTip: ProgressChangedEventArgs takes an int, but does not force it to be no more than 100. To report a larger percentage of progress, pass an argument with a multiplier (say 100), so 14.32% will be Progress 1432. Then you can format the display or override the progress bar or show its like a text box. (all with a dry design)
source
share