示例#1
0
 public Task Execute(IJobExecutionContext context)
 {
     return(Task.Run(() =>
     {
         JobExecuted = (context.JobDetail.JobDataMap.Get(EventKey) as JobExecutedEventHandler);
         JobExecuted?.Invoke(this, context);
     }));
 }
示例#2
0
        public Task ExecuteAsync(DateTime dateTime, CancellationToken cancellationToken)
        {
            foreach (var cronSchedule in _cronSchedules)
            {
                if (!cronSchedule.IsTime(dateTime))
                {
                    continue;
                }

                JobExecuting?.Invoke(this, Name);

                return(Task.Run(_func, cancellationToken).ContinueWith(x => JobExecuted?.Invoke(this, Name)));
            }

            return(Task.CompletedTask);
        }
示例#3
0
        public Task RunAsync(Func <Task> func, CancellationToken cancellationToken, string name)
        {
            JobExecuting?.Invoke(this, name);

            return(Task.Run(func, cancellationToken).ContinueWith(x => JobExecuted?.Invoke(this, name)));
        }
示例#4
0
 private void Job_JobExecuted(object sender, string name)
 {
     JobExecuted?.Invoke(sender, name);
 }