private void ScanFile(CASCFile file) { if (scanBackgroundWorker.CancellationPending) { throw new OperationCanceledException(); } NumScanned++; var fileNames = scanner.ScanFile(file); if (fileNames.Any()) { // only report progress when not skipping a file, it's faster that way int progress = (int)(NumScanned / (float)NumFiles * 100); ScanProgressState state = new ScanProgressState(); state.NumFilesScanned = NumScanned; state.NumFilesTotal = NumFiles; state.CurrentFileName = file.FullName; scanBackgroundWorker.ReportProgress(progress, state); foreach (var fileName in fileNames) { ulong hash = Hasher.ComputeHash(fileName); if ((CASC.Root as WowRootHandler).IsUnknownFile(hash)) { BeginInvoke((MethodInvoker)(() => UpdateFileNames(fileName, file.FullName))); } } } }
private void scanBackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { scanProgressBar.Value = e.ProgressPercentage; if (e.UserState is ScanProgressState) { ScanProgressState state = (ScanProgressState)e.UserState; scanLabel.Text = "Scanning '" + state.CurrentFileName + "' ..."; progressLabel.Text = state.NumFilesScanned + "/" + state.NumFilesTotal; } }
/// <summary>Constructs the <see cref="ScanEventArgs"/> without an exception.</summary> public ScanEventArgs(ScanState state, ScanProgressState progress) { ScanState = state; ProgressState = progress; Exception = null; }
/// <summary>Constructs the <see cref="ScanEventArgs"/> with an exception.</summary> public ScanEventArgs(ScanState state, ScanProgressState progress, Exception exception) { ScanState = state; ProgressState = progress; Exception = exception; }
private void ScanFile(CASCFile file) { if (scanBackgroundWorker.CancellationPending) throw new OperationCanceledException(); NumScanned++; var fileNames = scanner.ScanFile(file); if (fileNames.Any()) { // only report progress when not skipping a file, it's faster that way int progress = (int)(NumScanned / (float)NumFiles * 100); ScanProgressState state = new ScanProgressState(); state.NumFilesScanned = NumScanned; state.NumFilesTotal = NumFiles; state.CurrentFileName = file.FullName; scanBackgroundWorker.ReportProgress(progress, state); foreach (var fileName in fileNames) { ulong hash = Hasher.ComputeHash(fileName); if ((CASC.Root as WowRootHandler).IsUnknownFile(hash)) { BeginInvoke((MethodInvoker)(() => UpdateFileNames(fileName, file.FullName))); } } } }