Ejemplo n.º 1
0
        // This method is called on a worker thread (via asynchronous
        // delegate invocation).  This is where we call the operation (as
        // defined in the deriving class's DoWork method).
        public void InternalStart()
        {
            // isRunning is set during Start to avoid a race condition
            try
            {
                Spec = CurrentModule.ParseSpecification(this.Text, Options, File);

                OnReturnResult();
            }
            catch (CancelRunningException)
            {
                AcknowledgeCancel();
            }
            catch (Exception e)
            {
                // Raise the Failed event.  We're in a catch handler, so we
                // had better try not to throw another exception.
                try
                {
                    if (e is System.OutOfMemoryException)
                    {
                        e = new PAT.Common.Classes.Expressions.ExpressionClass.OutOfMemoryException("");
                    }

                    FailOperation(e);
                }
                catch
                {
                }

                // The documentation recommends not catching
                // SystemExceptions, so having notified the caller we
                // rethrow if it was one of them.
                if (e is SystemException)
                {
                    throw;
                }
            }


            lock (this)
            {
                // If the operation wasn't cancelled (or if the UI thread
                // tried to cancel it, but the method ran to completion
                // anyway before noticing the cancellation) and it
                // didn't fail with an exception, then we complete the
                // operation - if the UI thread was blocked waiting for
                // cancellation to complete it will be unblocked, and
                // the Completion event will be raised.
                if (!cancelAcknowledgedFlag && !failedFlag)
                {
                    CompleteOperation();
                }
            }
        }
Ejemplo n.º 2
0
 private void PrintErrorMsg(Exception ex)
 {
     EnableControls();
     if (ex is RuntimeException)
     {
         Utility.Utilities.LogRuntimeException(ex as RuntimeException);
         //MessageBox.Show("Runtime exception!\r\n" + ex.Message,// + "\r\n" + ex.StackTrace, "PAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (ex is System.OutOfMemoryException)
     {
         PAT.Common.Classes.Expressions.ExpressionClass.OutOfMemoryException outex =
             new PAT.Common.Classes.Expressions.ExpressionClass.OutOfMemoryException("");
         Utility.Utilities.LogRuntimeException(outex);
         //MessageBox.Show("Runtime exception!\r\n" + ex.Message,// + "\r\n" + ex.StackTrace, "PAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         Utility.Utilities.LogException(ex, Spec);
         //MessageBox.Show("Exception happened during the simulation: " + ex.Message, //"\r\n" + ex.StackTrace,"PAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }