本文整理汇总了C#中System.Threading.ThreadExceptionEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# ThreadExceptionEventArgs类的具体用法?C# ThreadExceptionEventArgs怎么用?C# ThreadExceptionEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThreadExceptionEventArgs类属于System.Threading命名空间,在下文中一共展示了ThreadExceptionEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application_ThreadException
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
string str = GetExceptionMsg(e.Exception, e.ToString());
Loger.Error(str);
//MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
//LogManager.WriteLog(str);
}
示例2: Application_ThreadException
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
var message =
e.Exception.Message + Environment.NewLine + e.Exception.Source + Environment.NewLine + e.Exception.StackTrace
+ Environment.NewLine + e.Exception.InnerException;
new Error().Add(message);
}
示例3: Application_ThreadException
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
//MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
// here you can log the exception ...
logger.Log(LogLevel.Debug, e.Exception.Message);
}
示例4: Application_ThreadException
// Handle the UI exceptions by showing a dialog box, and asking the user whether
// or not they wish to abort execution.
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs t)
{
try
{
reportError(t.Exception);
}
catch (Exception) { }
DialogResult result = DialogResult.Cancel;
try
{
result = ShowThreadExceptionDialog("Windows Forms Error", t.Exception);
}
catch
{
try
{
MessageBox.Show("Fatal Windows Forms Error",
"Fatal Windows Forms Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
}
finally
{
Application.Exit();
}
}
// Exits the program when the user clicks Abort.
if (result == DialogResult.Abort)
Application.Exit();
}
示例5: Application_ThreadException
// Handle the UI exceptions by showing a dialog box, and asking the user whether or not they wish to abort execution.
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
var exc = e.Exception;
// Ignore CultureNotFoundException to avoid error when changing language (on some computers) - see https://github.com/SubtitleEdit/subtitleedit/issues/719
if (!(exc is System.Globalization.CultureNotFoundException))
{
var dr = DialogResult.Abort;
try
{
var cap = "Windows Forms Thread Exception";
var msg = "An application error occurred in Subtitle Edit." +
"\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" +
"\n\nError Message:\n" + exc.Message +
"\n\nStack Trace:\n" + exc.StackTrace;
dr = MessageBox.Show(msg, cap, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
}
catch
{
}
if (dr == DialogResult.Abort)
{
Application.Exit();
}
}
}
示例6: catchUIThreadException
static void catchUIThreadException(object sender, ThreadExceptionEventArgs args)
{
Exception e = args.Exception;
MessageBox.Show("An unhandled thread exception has occured." + Environment.NewLine
+"Error Message: " + e.Message + Environment.NewLine
+"Stacktrace: " + e.StackTrace,"Unexpected Exception",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
示例7: OnThreadException
private void OnThreadException(object sender, ThreadExceptionEventArgs e)
{
if (!this.CanIgnoreException(e.Exception))
{
DialogResult cancel = DialogResult.Cancel;
try
{
cancel = this.ReportException(e.Exception);
}
catch
{
try
{
this.ReportFatalException(e.Exception);
}
finally
{
cancel = DialogResult.Abort;
}
}
if (cancel == DialogResult.Abort)
{
Application.Exit();
}
}
}
示例8: ApplicationThreadException
static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e)
{
if (e != null)
{
WriteError(e.Exception);
}
}
示例9: HandleThreadException
public static void HandleThreadException (object sender, ThreadExceptionEventArgs args)
{
_thisForm.Refresh ();
Application.DoEvents ();
HasHandledException = true;
_thisForm.Close ();
}
示例10: OnThreadException
// Handles the exception event.
public void OnThreadException(object sender, ThreadExceptionEventArgs t)
{
DialogResult result = System.Windows.Forms.DialogResult.Cancel;
try
{
result = this.ShowThreadExceptionDialog(t.Exception);
}
catch
{
try
{
MessageBox.Show("Fatal Error", "Fatal Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
}
finally
{
Application.Exit();
}
}
// Exits the program when the user clicks Abort.
if (result == System.Windows.Forms.DialogResult.Abort)
{
// if (frm.SaveModel(true))
// {
Application.Exit();
// }
}
}
示例11: UIThreadException
private static void UIThreadException(object sender, ThreadExceptionEventArgs t)
{
DialogResult result = DialogResult.Cancel;
try
{
Exception ex = (Exception)t.Exception;
string errorMsg = "UIThreadException\r\n\r\n";
errorMsg += "Oops, gInk crashed! Please include the following information if you plan to contact the developers (a copy of the following information is stored in crash.txt in the application folder):\r\n\r\n";
errorMsg += ex.Message + "\r\n\r\n";
errorMsg += "Stack Trace:\r\n" + ex.StackTrace + "\r\n\r\n";
WriteErrorLog(errorMsg);
errorMsg += "!!! PLEASE PRESS ESC KEY TO EXIT IF YOU FEEL YOUR MOUSE CLICK IS BLOCKED BY SOMETHING";
ShowErrorDialog("UIThreadException", errorMsg);
}
catch
{
try
{
MessageBox.Show("Fatal Windows Forms Error", "Fatal Windows Forms Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
}
finally
{
Application.Exit();
}
}
// Exits the program when the user clicks Abort.
if (result == DialogResult.Abort)
Application.Exit();
}
示例12: PrintError
private static void PrintError(object sender, ThreadExceptionEventArgs args)
{
using (var writer = new StreamWriter("error.log", false))
{
writer.Write(args.Exception.ToString());
}
}
示例13: Application_ThreadException
// Unhandled UI exceptions (can ignore and resume)
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs t)
{
DialogResult result = DialogResult.Abort;
try
{
if (logUiExceptionsOnly)
{
Console.WriteLine("EXCEPTION: " + ((Exception)t.Exception).ToString() + "");
result = DialogResult.Ignore;
}
else
{
Exception ex = (Exception)t.Exception;
string error =
"Sorry, an application error occurred (unhandled UI exception).\r\n\r\n" +
"Exception: " + ex.ToString() + "\r\n\r\n" +
"Stack trace: " + ex.StackTrace + "";
result = MessageBox.Show(error, Application.ProductName, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
}
}
catch { ; }
finally
{
if (result == DialogResult.Abort) { Application.Exit(); }
}
}
示例14: Application_ThreadException
void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
string err = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
if (e.Exception.InnerException != null)
err += Environment.NewLine + e.Exception.InnerException.Message + Environment.NewLine + e.Exception.InnerException.StackTrace;
txtRet.Text = err;
}
示例15: UIThreadExceptionHandler
/// <summary>
/// Handle for untrapped thread exceptions.
/// </summary>
/// <param name="sender">
/// Sender object.
/// </param>
/// <param name="t">
/// Exception event arguments.
/// </param>
private static void UIThreadExceptionHandler(object sender, ThreadExceptionEventArgs t)
{
DialogResult result = DialogResult.Cancel;
try
{
result = Program.ShowThreadExceptionDialog(t.Exception);
}
catch
{
try
{
string text = "Fatal " + ErrorTitle;
MessageBox.Show(text, text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
}
finally
{
Application.Exit();
}
}
// Exits the program when the user clicks Abort.
if (result == DialogResult.Abort)
{
Application.Exit();
}
}