void OutputFile() { List <int> printcols = new List <int>(); BackgroundWorker worker = new BackgroundWorker(); worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { MessageBox.Show("File output complete"); }; worker.DoWork += delegate(object s, DoWorkEventArgs args) { printcols = GetPrintCols(LiveCollection); IExportFile file = new ExportFile(_sessionColumnCollection, data.AsDataView(), printcols); file.OutputFile(OutputFileLocation); List <StationSummarySheetType> runSheets = new List <StationSummarySheetType>(); foreach (SelectionItem <StationSummarySheetType> Item in SummarySheets.selectedItems) { runSheets.Add(Item.SelectedItem); } XbyYShearStationSummary summary = new XbyYShearStationSummary(_sessionColumnCollection, data.AsDataView(), 30, 10, 2, _ogrid, runSheets); summary.CreateReport(OutputSummaryFileLocation); }; worker.RunWorkerAsync(); }