void scan_ScanProgressChanged(object sender, ScanProgressChangedEventArgs e) { if (this.InvokeRequired) { Progress progress = new Progress(scan_ScanProgressChanged); this.Invoke(progress, new object[] { sender, e }); } else { if (e.Progress > 100) e.Progress = 100; ProgressBar.Value = e.Progress; if (e.Progress == 100) { ScanTimeLabel.Text = "Time: " + ScanTimeStopwatch.ElapsedMilliseconds.ToString(); ScanTimeStopwatch.Stop(); AddressCount.Text = "Items: Sorting..."; } } }
//Update scan progress private void UpdateProgress(int ecx) { //Only update if new progress is higher (can be lower due to multithreading) if (Progress < (int)(((double)ecx / (double)(RegionCount-1)) * 100d)) { Progress = (int)(((double)ecx / (double)(RegionCount - 1)) * 100d); ScanProgressEventArgs = new ScanProgressChangedEventArgs(Progress); ScanProgressChanged(this, ScanProgressEventArgs); } }