📄 main.cs
字号:
using System;
using System.Configuration;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Windows.Forms;
namespace BufferedUploadWin
{
/// <summary>
/// Summary description for Main.
/// </summary>
class AppStart
{
[STAThread]
public static void Main()
{
try
{
SubMain();
}
catch (Exception e)
{
HandleUnhandledException(e);
}
}
public static void SubMain()
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException); // CLR
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(OnGuiUnhandedException); // Windows Forms
Application.EnableVisualStyles();
Application.Run(new Form1());
}
// CLR unhandled exception
public static void OnUnhandledException(Object sender, UnhandledExceptionEventArgs e)
{
HandleUnhandledException(e.ExceptionObject);
}
// Windows Forms unhandled exception
public static void OnGuiUnhandedException(Object sender, ThreadExceptionEventArgs e)
{
HandleUnhandledException(e.Exception);
}
public static void HandleUnhandledException(Object o)
{
if(o == null)
{
MessageBox.Show("An unknown error has occurred in this app. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Exception ex = o as Exception;
if (ex != null)
{
if(ex.GetType().Name == "ThreadAbortException")
return; // ignore. these are in response to the user cancelling a thread, so don't report any errors.
else
{
MessageBox.Show(ex.ToString());
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -