protected internal override PvmExecutionImpl EventNotificationsStarted(PvmExecutionImpl execution)
        {
            execution.IncrementSequenceCounter();

            // hack around execution tree structure not being in sync with activity instance concept:
            // if we end a scope activity, take remembered activity instance from parent and set on
            // execution before calling END listeners.
            var          parent   = execution.Parent;
            IPvmActivity activity = execution.Activity;

            if ((parent != null) && execution.IsScope && (activity != null) && activity.IsScope &&
                (activity.ActivityBehavior is ICompositeActivityBehavior ||
                 (CompensationBehavior.IsCompensationThrowing(execution) &&
                  !LegacyBehavior.IsCompensationThrowing(execution))))
            {
                Log.DebugLeavesActivityInstance(execution, execution.ActivityInstanceId);

                // use remembered activity instance id from parent
                execution.ActivityInstanceId = parent.ActivityInstanceId;
                // make parent go one scope up.
                parent.LeaveActivityInstance();
            }

            return(execution);
        }
        protected internal override PvmExecutionImpl EventNotificationsStarted(PvmExecutionImpl execution)
        {
            execution.IncrementSequenceCounter();
            execution.ActivityInstanceStarting();
            execution.EnterActivityInstance();

            return(execution);
        }