Rewritten the T-Balancer code to use the FTDI D2XX drivers directly instead of the System.IO.Ports.SerialPort class. The SerialPort class has some ugly problems like http://connect.microsoft.com/VisualStudio/feedback/details/140018/serialport-crashes-after-disconnect-of-usb-com-port or http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/8a1825d2-c84b-4620-91e7-3934a4d47330 for which no real solution seems to exist. And Microsoft doesn't feel like it needs to be fixed for years now.
This commit is contained in:
+27
-4
@@ -48,6 +48,11 @@ namespace OpenHardwareMonitor {
|
||||
[STAThread]
|
||||
public static void Main() {
|
||||
#if !DEBUG
|
||||
Application.ThreadException +=
|
||||
new ThreadExceptionEventHandler(Application_ThreadException);
|
||||
Application.SetUnhandledExceptionMode(
|
||||
UnhandledExceptionMode.CatchException);
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException +=
|
||||
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
#endif
|
||||
@@ -62,13 +67,31 @@ namespace OpenHardwareMonitor {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReportException(Exception e) {
|
||||
CrashReportForm form = new CrashReportForm();
|
||||
form.Exception = e;
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
public static void Application_ThreadException(object sender,
|
||||
ThreadExceptionEventArgs e)
|
||||
{
|
||||
try {
|
||||
ReportException(e.Exception);
|
||||
} catch {
|
||||
} finally {
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void CurrentDomain_UnhandledException(object sender,
|
||||
UnhandledExceptionEventArgs args)
|
||||
{
|
||||
CrashReportForm form = new CrashReportForm();
|
||||
form.Exception = (Exception)args.ExceptionObject;
|
||||
form.ShowDialog();
|
||||
Environment.Exit(0);
|
||||
try {
|
||||
Exception e = args.ExceptionObject as Exception;
|
||||
if (e != null)
|
||||
ReportException(e);
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user