private void OnExport(object sender, DoWorkEventArgs args) { var worker = (BackgroundWorker)sender; _exportType = (UploadWizardControl.ExportType)args.Argument; Action <int> reportExportStatusChange = percentage => worker.ReportProgress(percentage, string.Format("{0}%", percentage)); _exporter.ExportProgressChanged += reportExportStatusChange; try { var publisher = CreatePublisher(); args.Result = _exporter.Export(_exportTime, publisher); _logManager.DeleteLogsOlderThan(_exportTime); } finally { _exporter.ExportProgressChanged -= reportExportStatusChange; } }