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