static void Main(string[] args) { // Only one of the exception handlers below will be used: // - Application.ThreadException will be fired for a windows application // - System.AppDomain.CurrentDomain.UnhandledException will be fired for other applications. CustomExceptionHandler eh = new CustomExceptionHandler(); Application.ThreadException += new ThreadExceptionEventHandler(eh.OnThreadException); System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(eh.OnAppDomainUnhandledException); if (args.Length == 1) { if (args[0].ToLower().EndsWith(".pdvt")) { _StartWithProjectFile = args[0]; } if (args[0].ToLower().EndsWith(".ses")) { _StartWithSessionFile = args[0]; } } Application.Run(new MainForm()); // The application is closing, don't show any exceptions anymore. eh.ShowExceptions = false; }
private void OnEmulateVerificationScuDone(IAsyncResult ar) { try { _EmulatorSession.EndEmulateVerificationSCU(ar); } catch (Exception ex) { // // Problem: // Errors thrown from a workerthread are eaten by the .NET 1.x CLR. // Workaround: // Directly call the global (untrapped) exception handler callback. // Do NOT rely on // either // - System.AppDomain.CurrentDomain.UnhandledException // or // - System.Windows.Forms.Application.ThreadException // These events will only be triggered for the main thread not for worker threads. // CustomExceptionHandler eh = new CustomExceptionHandler(); System.Threading.ThreadExceptionEventArgs args = new ThreadExceptionEventArgs(ex); eh.OnThreadException(this, args); // // Rethrow. This rethrow may work in the future .NET 2.x CLR. // Currently eaten. // throw ex; } }
private void ExecuteVisualBasicScript() { try { ScriptFileTag theScriptFileTag = _TagThatIsBeingExecuted as ScriptFileTag; if (theScriptFileTag == null) // Sanity check. { Debug.Assert(false); } else { // TODO!!!!! // The following code should be removed when the business layer is completely implemented! // For now, construct a business layer object that does the execution of the VBS. // BEGIN DvtkApplicationLayer.VisualBasicScript applicationLayerVisualBasicScript = new DvtkApplicationLayer.VisualBasicScript(theScriptFileTag._Session as ScriptSession, theScriptFileTag._ScriptFileName); // END String[] emptyArray = {}; ArrayList listContainingExmptyArray = new ArrayList(); listContainingExmptyArray.Add(emptyArray); applicationLayerVisualBasicScript.Execute(listContainingExmptyArray.ToArray()); } // Update the UI. Do this with an invoke, because the thread that is calling this // method is NOT the thread that created all controls used! _EndExecution = new EndExecution(_TagThatIsBeingExecuted); _TagThatIsBeingExecuted = null; _NotifyDelegate = new NotifyDelegate(_ParentForm.Notify); _ParentForm.Invoke(_NotifyDelegate, new object[]{_EndExecution}); } catch (Exception ex) { // // Problem: // Errors thrown from a workerthread are eaten by the .NET 1.x CLR. // Workaround: // Directly call the global (untrapped) exception handler callback. // Do NOT rely on // either // - System.AppDomain.CurrentDomain.UnhandledException // or // - System.Windows.Forms.Application.ThreadException // These events will only be triggered for the main thread not for worker threads. // CustomExceptionHandler eh = new CustomExceptionHandler(); System.Threading.ThreadExceptionEventArgs args = new ThreadExceptionEventArgs(ex); eh.OnThreadException(this, args); // // Rethrow. This rethrow may work in the future .NET 2.x CLR. // Currently eaten. // throw ex; } }
public void ResultsFromValidateMediaFilesAsynchronously(IAsyncResult theIAsyncResult) { Dvtk.Sessions.MediaSession theMediaSession = (Dvtk.Sessions.MediaSession)GetExecutingSession(); try { // Obligated to call the following method according to the asynchronous design pattern. theMediaSession.EndValidateMediaFiles(theIAsyncResult); } catch (Exception ex) { // // Problem: // Errors thrown from a workerthread are eaten by the .NET 1.x CLR. // Workaround: // Directly call the global (untrapped) exception handler callback. // Do NOT rely on // either // - System.AppDomain.CurrentDomain.UnhandledException // or // - System.Windows.Forms.Application.ThreadException // These events will only be triggered for the main thread not for worker threads. // CustomExceptionHandler eh = new CustomExceptionHandler(); System.Threading.ThreadExceptionEventArgs args = new ThreadExceptionEventArgs(ex); eh.OnThreadException(this, args); // // Rethrow. This rethrow may work in the future .NET 2.x CLR. // Currently eaten. // throw ex; } theMediaSession.EndResultsGathering(); if (mediaFilesToBeValidated.Count > 0) { ValidateMediaFiles(); } else { // Update the UI. Do this with an invoke, because the thread that is calling this // method is NOT the thread that created all controls used! _EndExecution = new EndExecution(_TagThatIsBeingExecuted); _TagThatIsBeingExecuted = null; _NotifyDelegate = new NotifyDelegate(_ParentForm.Notify); _ParentForm.Invoke(_NotifyDelegate, new object[]{_EndExecution}); } }
private void ExecuteVisualBasicScript() { try { Script theScriptFileTag = _TagThatIsBeingExecuted as Script; if (theScriptFileTag == null) { // Sanity check. Debug.Assert(false); } else { DvtkApplicationLayer.VisualBasicScript applicationLayerVisualBasicScript = new DvtkApplicationLayer.VisualBasicScript(((DvtkApplicationLayer.ScriptSession)theScriptFileTag.ParentSession).ScriptSessionImplementation , theScriptFileTag.ScriptFileName); // END String[] emptyArray = {}; ArrayList listContainingExmptyArray = new ArrayList(); listContainingExmptyArray.Add(emptyArray); applicationLayerVisualBasicScript.Execute(listContainingExmptyArray.ToArray()); } // Update the UI. Do this with an invoke, because the thread that is calling this // method is NOT the thread that created all controls used! theScriptFileTag.ParentSession.IsExecute = false; Script script = (Script)_TagThatIsBeingExecuted ; ((ScriptSession)script.ParentSession).CreateScriptFiles(); _EndExecution = new EndExecution(_TagThatIsBeingExecuted); _TagThatIsBeingExecuted = null; _NotifyDelegate = new NotifyDelegate(parentForm.Notify); parentForm.Invoke(_NotifyDelegate, new object[]{_EndExecution}); } catch (Exception ex) { // // Problem: // Errors thrown from a workerthread are eaten by the .NET 1.x CLR. // Workaround: // Directly call the global (untrapped) exception handler callback. // Do NOT rely on // either // - System.AppDomain.CurrentDomain.UnhandledException // or // - System.Windows.Forms.Application.ThreadException // These events will only be triggered for the main thread not for worker threads. // CustomExceptionHandler eh = new CustomExceptionHandler(); System.Threading.ThreadExceptionEventArgs args = new ThreadExceptionEventArgs(ex); eh.OnThreadException(this, args); // // Rethrow. This rethrow may work in the future .NET 2.x CLR. // Currently eaten. // throw ex; } }