- Timestamp:
- Mar 29, 2011, 7:34:41 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
r1121 r1122 186 186 static void Main(string[] args) 187 187 { 188 //Application wide error handler for unhandled errors (later I figure out that's only for WinForm ex'es) 189 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); 190 Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException); 191 192 // Add the event handler for handling non-UI thread exceptions to the event. 193 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(App_DomainException); 194 188 195 #if DEBUG 189 196 // Print console messages to console if launched from console … … 231 238 Application.DoEvents(); 232 239 233 //Application wide error handler for unhandled errors 234 Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException); 240 //test 241 //doc.ThrowException(); 242 //test 235 243 236 244 #if TRACE … … 247 255 248 256 /// <summary> 249 /// Exception handler for application errors. TODO: Test 250 /// </summary> 257 /// Exception handler for application errors. Only for WinForm Errors. 258 /// </summary> 259 /// <remarks>Never tested. I can't get an error to go here!</remarks> 251 260 /// <param name="sender"></param> 252 261 /// <param name="e"></param> 253 262 static void App_ThreadException(object sender, ThreadExceptionEventArgs e) 254 263 { 255 if (e.Exception is System.Net.Sockets.SocketException)256 {257 MessageBox.Show("Looks like we lost our connection with the server\nClick OK to terminate the application.");258 Application.Exit();259 }260 261 264 string msg = "A problem has occured in this applicaton. \r\n\r\n" + 262 265 "\t" + e.Exception.Message + "\r\n\r\n" + … … 269 272 } 270 273 274 /// <summary> 275 /// If we are here, we are dead meat. 276 /// </summary> 277 /// <param name="sender"></param> 278 /// <param name="e"></param> 279 static void App_DomainException(object sender, UnhandledExceptionEventArgs e) 280 { 281 if (e.ExceptionObject is System.Net.Sockets.SocketException) 282 { 283 MessageBox.Show("Looks like we lost our connection with the server\nClick OK to terminate the application."); 284 } 285 else 286 { 287 Exception ex = e.ExceptionObject as Exception; 288 289 string msg = "A problem has occured in this applicaton. \r\n\r\n" + 290 "\t" + ex.InnerException.Message; 291 292 MessageBox.Show(msg, "Unexpected Error"); 293 } 294 }// here application terminates 271 295 272 296 #region BMXNet Event Handler
Note:
See TracChangeset
for help on using the changeset viewer.