Esempio n. 1
0
 public override void Execute(T parameter)
 {
     if (CanExecute(parameter))
     {
         MethodToExecute.Invoke(parameter);
     }
 }
Esempio n. 2
0
 // Method to use the delegate
 public static void ExecuteMethod(int t, MethodToExecute method)
 {
     while (true)
     {
         Thread.Sleep(t * 1000);
         method();
     }
 }
Esempio 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);
        }
Esempio n. 4
0
 public Timer(Action method, int timesToExecute, int delayTime)
 {
     this.methodToExecute = new MethodToExecute(method);
     this.TimesToExecute = timesToExecute;
     this.DelayTime = delayTime;
 }
Esempio n. 5
0
 public MenuOption(string displayTitle, MethodToExecute methodToExecute) : this(displayTitle)
 {
     this.methodToExecute = methodToExecute;
 }
Esempio n. 6
0
        private void addOption(List <IMenuOption> options, string displayTitle, MethodToExecute methodToExecute)
        {
            IMenuOption option = new MenuOption(displayTitle, methodToExecute);

            addOption(options, option);
        }