Пример #1
0
        private TimerExtension GetTimerExtension(ActivityContext context)
        {
            TimerExtension timerExtension = context.GetExtension <TimerExtension>();

            Fx.Assert(timerExtension != null, "TimerExtension must exist.");
            return(timerExtension);
        }
Пример #2
0
        protected override void Cancel(NativeActivityContext context)
        {
            Bookmark       timerBookmark  = this.timerBookmark.Get(context);
            TimerExtension timerExtension = GetTimerExtension(context);

            timerExtension.CancelTimer(timerBookmark);
            context.RemoveBookmark(timerBookmark);
            context.MarkCanceled();
        }
            private TimerExtension GetTimerExtension()
            {
                TimerExtension service = this.executor.GetService(typeof(TimerExtension)) as TimerExtension;

                if (service == null)
                {
                    throw new InvalidOperationException(ExecutionStringManager.InteropCantFindTimerExtension);
                }
                return(service);
            }
Пример #4
0
        protected override void Abort(NativeActivityAbortContext context)
        {
            Bookmark timerBookmark = this.timerBookmark.Get(context);

            // The bookmark could be null in abort when user passed in a negative delay as a duration
            if (timerBookmark != null)
            {
                TimerExtension timerExtension = GetTimerExtension(context);
                timerExtension.CancelTimer(timerBookmark);
            }
            base.Abort(context);
        }
Пример #5
0
        protected override void Execute(NativeActivityContext context)
        {
            TimeSpan actualValue = this.Duration.Get(context);

            if (actualValue < TimeSpan.Zero)
            {
                throw FxTrace.Exception.ArgumentOutOfRange("Duration", actualValue, System.Activities.SR.DurationIsNegative(base.DisplayName));
            }
            if (actualValue != TimeSpan.Zero)
            {
                TimerExtension timerExtension = this.GetTimerExtension(context);
                Bookmark       bookmark       = context.CreateBookmark();
                timerExtension.RegisterTimer(actualValue, bookmark);
                this.timerBookmark.Set(context, bookmark);
            }
        }
Пример #6
0
        protected override void Execute(NativeActivityContext context)
        {
            TimeSpan duration = this.Duration.Get(context);

            if (duration < TimeSpan.Zero)
            {
                throw FxTrace.Exception.ArgumentOutOfRange("Duration", duration, SR.DurationIsNegative(this.DisplayName));
            }

            if (duration == TimeSpan.Zero)
            {
                return;
            }

            TimerExtension timerExtension = GetTimerExtension(context);
            Bookmark       bookmark       = context.CreateBookmark();

            timerExtension.RegisterTimer(duration, bookmark);
            this.timerBookmark.Set(context, bookmark);
        }