/// <summary>
        /// Just before returning from method body.
        /// </summary>
        /// <remarks>Only method allowed to pop from callstack.</remarks>
        public override void LeaveMethod()
        {
            try
            {
                if (callStack.Count == 0)
                {
                    SafeDebug.Fail("cannot leave empty method");    //should not happen with the fake frame.
                    return;
                }

                if (callStack.Count == 1)
                {
                    this.callMonitor.RunCompleted();
                    return;    //exit from Main, if we did not get Enter(Main).
                }

                CallFrame poppedFrame = callStack.First.Value;
                callStack.RemoveFirst();
                this.current = callStack.First.Value;

                if (poppedFrame.PreemptionsDisabled && !this.current.PreemptionsDisabled)
                {
                    this.PreemptionEnable();
                }

                if (poppedFrame.Prioritized && !this.current.Prioritized)
                {
                    MChessChess.UnprioritizePreemptions();
                }
            }
            catch (Exception e)
            {
                LogException(e);
            }
        }
Exemple #2
0
 public static void UnprioritizePreemptions()
 {
     using (new WrapperSentry())
         MChessChess.UnprioritizePreemptions();
 }