|
namespace Test
{
using System;
using System.Threading;
using System.Windows.Forms;
static class Program
{
[STAThread]
static void Main()
{
Application.ThreadException +=
applicationThreadException;
Application.SetUnhandledExceptionMode(
UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException +=
currentDomainUnhandledException;
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TestForm());
}
catch (Exception e)
{
doHandleException(e);
}
}
private static void doHandleException(Exception x)
{
if (x is ObjectDisposedException)
{
// Eat.
}
else
{
MessageBox.Show(x.Message);
}
}
private static void currentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
doHandleException((Exception)e.ExceptionObject);
}
private static void applicationThreadException(object sender, ThreadExceptionEventArgs e)
{
doHandleException(e.Exception);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.