void DoConvert(object sender, DoWorkEventArgs e) { TraceOutput("Starting conversion."); var fiSource = new DirectoryInfo(txtSourceFolder.Text); var datFiles = fiSource.EnumerateFiles("*.dat"); TraceOutput("{0} files found for conversion.", datFiles.Count()); var isConversionCompletedEvents = new ManualResetEvent[datFiles.Count()]; _convertSingleFileParameters = new List <ConvertSingleFileParameters>(); var i = 0; foreach (var file in datFiles) { isConversionCompletedEvents[i] = new ManualResetEvent(false); var convertSingleFileParameters = new ConvertSingleFileParameters(file, isConversionCompletedEvents[i]); _convertSingleFileParameters.Add(convertSingleFileParameters); ThreadPool.QueueUserWorkItem(ConvertSingleFile, convertSingleFileParameters); i++; } WaitHandle.WaitAll(isConversionCompletedEvents); }
void DoConvert(object sender, DoWorkEventArgs e) { TraceOutput("Starting conversion."); var fiSource = new DirectoryInfo(txtSourceFolder.Text); var datFiles = fiSource.EnumerateFiles("*.dat"); TraceOutput("{0} files found for conversion.", datFiles.Count()); var isConversionCompletedEvents = new ManualResetEvent[datFiles.Count()]; _convertSingleFileParameters = new List<ConvertSingleFileParameters>(); var i = 0; foreach (var file in datFiles) { isConversionCompletedEvents[i] = new ManualResetEvent(false); var convertSingleFileParameters = new ConvertSingleFileParameters(file, isConversionCompletedEvents[i]); _convertSingleFileParameters.Add(convertSingleFileParameters); ThreadPool.QueueUserWorkItem(ConvertSingleFile, convertSingleFileParameters); i++; } WaitHandle.WaitAll(isConversionCompletedEvents); }