public void AsynchronousExecutionAborted(Exception ex) { if (!this.InvokeRequired) { progressBar1.Value = 0; this.Enabled = true; lblProgresso.Text = String.Empty; MessageBox.Show(String.Format( "Ocorreu o seguinte erro durante a tentativa de geração do arquivo: {0} - {1}\r\n\r\n{2}", ex.GetType().ToString(), ex.Message, ex.StackTrace)); } else { AsynchronousExecutionAbortedDelegate executionAborted = new AsynchronousExecutionAbortedDelegate(AsynchronousExecutionAborted); this.BeginInvoke(executionAborted, new object[] { ex }); } }