分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
using Quartz;using System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Text;namespace Examples{ public class JobDurationListenerExample : IJobListener { public void JobExecutionVetoed(IJobExecutionContext context) { // Do nothing } public void JobToBeExecuted(IJobExecutionContext context) { var stopwatch = new Stopwatch(); stopwatch.Start(); Console.WriteLine("Job {0} in group {1} is about to be executed", context.JobDetail.Key.Name, context.JobDetail.Key.Group); _Stopwatches.Add(context.FireInstanceId, stopwatch); } public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException) { var elapsed = _Stopwatches[context.FireInstanceId].ElapsedMilliseconds; Console.WriteLine("Job {0} in group {1} was executed in {2}ms", context.JobDetail.Key.Name, context.JobDetail.Key.Group, elapsed); } public string Name { get { return "JobDurationListener"; } } private Dictionary<string, Stopwatch> _Stopwatches = new Dictionary<string, Stopwatch>(); }}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
注册监听器
//Adding a JobListener that is interested in a particular job:scheduler.ListenerManager.AddJobListener(myJobListener, KeyMatcher<JobKey>.KeyEquals(new JobKey("myJobName", "myJobGroup")));//Adding a JobListener that is interested in all jobs of a particular group:scheduler.ListenerManager.AddJobListener(myJobListener, GroupMatcher<JobKey>.GroupEquals("myJobGroup"));//Adding a JobListener that is interested in all jobs of two particular groups:scheduler.ListenerManager.AddJobListener(myJobListener, OrMatcher<JobKey>.Or(GroupMatcher<JobKey>.GroupEquals("myJobGroup"), GroupMatcher<JobKey>.GroupEquals("yourGroup")));//Adding a JobListener that is interested in all jobs:scheduler.ListenerManager.AddJobListener(myJobListener, GroupMatcher<JobKey>.AnyGroup());
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow