public Task Execute(IJobExecutionContext context) { return(Task.Run(() => { JobExecuted = (context.JobDetail.JobDataMap.Get(EventKey) as JobExecutedEventHandler); JobExecuted?.Invoke(this, context); })); }
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); }
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))); }
private void Job_JobExecuted(object sender, string name) { JobExecuted?.Invoke(sender, name); }