private void ResetAndEnsure(BatchOptions options) { ///////////////////////////////// // Ensure if (IsBusy) { throw new InvalidOperationException("The BatchProcess is busy processing another operation."); } IsBusy = true; if (options == null) { throw new ArgumentNullException("options"); } ///////////////////////////////// // Reset State Log.Clear(); Cancel = false; Options = options; }
public void Process(BatchOptions options) { ResetAndEnsure(options); try { OnMajorProgressChanged(-1, -1, "Enumerating files"); // get a list of files from the directory FileInfo[] files = GetFiles(); FilesCount = files.Length; for (int i = 0; i < files.Length; i++) { if (Cancel) { break; } FileInfo file = files[i]; OnMajorProgressChanged(i, files.Length, file.Name); ProcessFile(file); FilesDone = i; } String logFilename = Path.Combine(options.ExportDirectory.FullName, "Export Log.txt"); Log.Save(logFilename); } finally { IsBusy = false; } }