Exemplo n.º 1
0
 public override void Execute(T parameter)
 {
     if (CanExecute(parameter))
     {
         MethodToExecute.Invoke(parameter);
     }
 }
Exemplo n.º 2
0
 // Method to use the delegate
 public static void ExecuteMethod(int t, MethodToExecute method)
 {
     while (true)
     {
         Thread.Sleep(t * 1000);
         method();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Add a job to the Scheduler.
        /// </summary>
        /// <param name="cronJobText">define the cron job: e.g. 0/5 * * * * ? for every 5 second </param>
        /// <param name="methodToExecute">define which method should be executed</param>
        /// <param name="parameters">the parameters that should be used in the methods (thread safe)</param>
        /// <param name="AllowConcurrentExecution">define if the scheduler allows a second call even if the first is not finished</param>
        public void AddJob(string cronJobText, MethodToExecute methodToExecute, Dictionary <string, object> parameters, bool AllowConcurrentExecution)
        {
            IJobDetail jobDetail = AllowConcurrentExecution ?
                                   JobBuilder.Create <QuartzJob>().Build() :
                                   JobBuilder.Create <QuartzJobConcurrentExecution>().Build();

            jobDetail.JobDataMap.Add(
                "JobParameters",
                new Tuple <MethodToExecute, Dictionary <string, object> >(methodToExecute, parameters));
            var trigger = TriggerBuilder.Create()
                          .WithCronSchedule(cronJobText) //"0 23 15,16,17 ? * *"
                          .Build();

            _Scheduler.ScheduleJob(jobDetail, trigger);
        }
Exemplo n.º 4
0
 public Timer(Action method, int timesToExecute, int delayTime)
 {
     this.methodToExecute = new MethodToExecute(method);
     this.TimesToExecute = timesToExecute;
     this.DelayTime = delayTime;
 }
Exemplo n.º 5
0
 public MenuOption(string displayTitle, MethodToExecute methodToExecute) : this(displayTitle)
 {
     this.methodToExecute = methodToExecute;
 }
Exemplo n.º 6
0
        private void addOption(List <IMenuOption> options, string displayTitle, MethodToExecute methodToExecute)
        {
            IMenuOption option = new MenuOption(displayTitle, methodToExecute);

            addOption(options, option);
        }