Beispiel #1
0
        /// <summary>
        /// Enables the trigger.
        /// </summary>
        /// <param name="context">
        /// The trigger context.
        /// </param>
        public void Enable(ITriggerContext context)
        {
            if (this.handler != null)
            {
                this.Disable(context);
            }

            this.handler = (o, e) =>
            {
                if (string.Equals(this.jobName, e.JobName, StringComparison.OrdinalIgnoreCase))
                {
                    context.Activate();
                }
            };

            context.JobExecuted += this.handler;
        }
Beispiel #2
0
        /// <summary>
        /// Enables the trigger.
        /// </summary>
        /// <param name="context">
        /// The trigger context.
        /// </param>
        public void Enable(ITriggerContext context)
        {
            if (this.tokenSource != null)
            {
                return;
            }

            this.tokenSource = new CancellationTokenSource();

            Func <Task> wait = async() =>
            {
                while (!this.tokenSource.IsCancellationRequested)
                {
                    await Task.Delay(this.interval, this.tokenSource.Token).ConfigureAwait(false);

                    if (!this.tokenSource.IsCancellationRequested)
                    {
                        context.Activate();
                    }
                }
            };

            wait();
        }