/[EmuXPortal]/branches/mono/EmuXPortal/Form1.cs
ViewVC logotype

Diff of /branches/mono/EmuXPortal/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 241 by william, Tue Aug 5 05:19:39 2014 UTC revision 243 by william, Tue Aug 5 05:57:55 2014 UTC
# Line 28  namespace EmuXPortal Line 28  namespace EmuXPortal
28          IEmuConfig CurrentSelectedRom = null;          IEmuConfig CurrentSelectedRom = null;
29          PlatformControl CurrentPlatformControl = null;          PlatformControl CurrentPlatformControl = null;
30          GameControl CurrentGameControl = null;          GameControl CurrentGameControl = null;
31    
32            #region unhandled exception support
33            static void Application_Unhandled_ThreadException(object sender, ThreadExceptionEventArgs e)
34            {
35                UnhandledExceptionEventArgs uea = new UnhandledExceptionEventArgs(e.Exception, false);
36                UnhandledExceptionEventHandler(sender, uea);
37            }
38            static void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs args)
39            {            
40                Exception ex = (args.ExceptionObject as Exception);
41                if (sender == null)
42                {
43                    gLog.Error.WriteLine("Caught an unhandled exception from an unkown source");
44                }
45                else
46                {
47                    gLog.Error.WriteLine("Caught an unhandled exception from type: {0}", sender.GetType().Name);
48                }
49    
50                if (ex == null)
51                {
52                    gLog.Error.WriteLine("The exception object was null -- it probably is not derived from System.Exception");
53                }
54                else
55                {
56                    ex = ex.GetBaseException();
57                    gLog.Error.WriteLine("{0}:", ex.GetType().Name);
58                    gLog.Verbose.Error.WriteLine(ex.ToString());
59                }            
60                
61            }
62            #endregion
63          public Form1()          public Form1()
64          {          {
65              InitializeComponent();                        InitializeComponent();
66    
67            
68              #region logging support              #region logging support
69              string log_path = Application.StartupPath;              string log_path = Application.StartupPath;
70              string log_filename = string.Format("{0}.log", typeof(Form1).Assembly.GetName().Name);              string log_filename = string.Format("{0}.log", typeof(Form1).Assembly.GetName().Name);
# Line 59  namespace EmuXPortal Line 93  namespace EmuXPortal
93  #endif  #endif
94              #endregion              #endregion
95    
96                #region unhandled exception support
97                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);
98                Application.ThreadException += Application_Unhandled_ThreadException;
99                #endregion
100    
101              platform_flow.Dock = DockStyle.Fill;              platform_flow.Dock = DockStyle.Fill;
102              rom_flow.Dock = DockStyle.Fill;              rom_flow.Dock = DockStyle.Fill;
103          }          }
104    
105          
106    
107          
108  #region logging support  #region logging support
109          StringBuilder log_flusher = new StringBuilder();          StringBuilder log_flusher = new StringBuilder();
110          void Log_OnFlush(object sender, LoggerOnFlushEventArgs e) { OnLogFlush(e.Buffer); }          void Log_OnFlush(object sender, LoggerOnFlushEventArgs e) { OnLogFlush(e.Buffer); }

Legend:
Removed from v.241  
changed lines
  Added in v.243

  ViewVC Help
Powered by ViewVC 1.1.22