123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Threading;
- using Aitex.Core.RT.Log;
- using Aitex.RT;
- namespace Aitex.Triton160.RT
- {
- static class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
- AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
- //Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result.
- Application.ThreadException += ThreadHandler;
- Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new RtApplication());
- }
- static ThreadExceptionEventHandler ThreadHandler = new ThreadExceptionEventHandler(Application_ThreadException);
- static void CurrentDomain_ProcessExit(object sender, EventArgs e)
- {
- Application.ThreadException -= ThreadHandler;
- }
- static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- {
- ShowMessageDialog(e.Exception);
- }
- static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- ShowMessageDialog((Exception)e.ExceptionObject);
- }
- static void ShowMessageDialog(Exception ex)
- {
- try
- {
- LOG.Write(ex);
- string message = string.Format("Triton160 RT进程异常退出:{0}。\n", DateTime.Now);
- MessageBox.Show(message + ex.Message);
- }
- finally
- {
- Environment.Exit(0);
- }
- }
- }
- }
|