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:
Michael Möller
2010-04-05 15:31:19 +00:00
parent 20158a0edd
commit 76a3ac113b
6 changed files with 368 additions and 132 deletions
+27 -4
View File
@@ -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 { }
}
}
}