protected void bgOutputWorker_DoWork(object sender, DoWorkEventArgs e) { try { _thHashMonitor.Start(); if (OutputList != null) { while (_thHashMonitor.IsAlive) { if (OutputList.Count > 0) { OutputDataStruct tempResultData = OutputList.Take(); if (tempResultData != null) { _bgOutputWorker.ReportProgress(OutputList.Count, tempResultData); } } } } } catch (Exception ex) { result = ShowThreadExceptionDialog("Error occured.", ex); // Exits the program when the user clicks Abort. if (result == DialogResult.Abort) { Environment.Exit(0); } } }
protected void bgOutputWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { OutputDataStruct tempResultData = (OutputDataStruct)e.UserState; _duplicateFilesFound++; lstBoxResults.Items.Add(tempResultData.FileName1 + @" <==> " + tempResultData.FileName2); lblDuplicateCounter.Text = _duplicateFilesFound + @" Duplicate file(s) found out of " + _totalFilesToScan + @" files."; using (StreamWriter outputResultFile = new StreamWriter(_outputFile, true)) { outputResultFile.WriteLine("#{0} [{1}] - Thread{4}: {2} = {3}", _duplicateFilesFound, DateTime.Now.ToString(CultureInfo.CurrentCulture), tempResultData.FileName1, tempResultData.FileName2, tempResultData.ThreadId.ToString()); } }