本文整理汇总了C#中IScheduler.Shutdown方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.Shutdown方法的具体用法?C# IScheduler.Shutdown怎么用?C# IScheduler.Shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScheduler
的用法示例。
在下文中一共展示了IScheduler.Shutdown方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Service
public Service()
{
InitializeComponent();
try
{
XmlConfigurator.Configure();
log.Info("--------------------- Initializing Service ----------------------");
schedulerFactory = new StdSchedulerFactory();
scheduler = schedulerFactory.GetScheduler();
IJobDetail job = JobBuilder.Create<TwitterServiceWrapper>()
.WithIdentity("TwitterServiceJobr")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("TwitterTrigger")
.WithCronSchedule(CronExpression)
.Build();
scheduler.ScheduleJob(job, trigger);
}
catch (Exception ex)
{
log.Error("Fatall error Initializing Windows Service", ex);
if (scheduler != null && scheduler.IsStarted)
scheduler.Shutdown();
}
}
示例2: Main
static void Main(string[] args)
{
Console.WriteLine("Starting scheduler...");
var properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "RemoteServerTestScheduler";
// set thread pool infoD:\Projects\QuartzMaster\QuartzMaster.TestServerHost\Program.cs
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "5";
properties["quartz.threadPool.threadPriority"] = "Normal";
// set remoting expoter
properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz";
properties["quartz.scheduler.exporter.port"] = "500";
properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
properties["quartz.scheduler.exporter.channelType"] = "tcp";
var schedulerFactory = new StdSchedulerFactory(properties);
scheduler = schedulerFactory.GetScheduler();
// define the job and ask it to run
var map = new JobDataMap();
map.Put("msg", "Some message!");
map.Put("msg 2", "Some message 2!");
map.Put("msg 3", "Some message 3!");
var job = new JobDetail("localJob", "default", typeof(NoOpJob))
{
JobDataMap = map
};
var job2 = new JobDetail("localJob 2", "default", typeof(NoOpJob))
{
JobDataMap = map
};
var trigger2 = new SimpleTrigger("Simple Trigger", "default", "localJob 2", "default", DateTime.Now, DateTime.Now.AddMinutes(10), SimpleTrigger.RepeatIndefinitely, new TimeSpan(0, 0, 45));
var trigger = new CronTrigger("remotelyAddedTrigger", "default", "localJob", "default", DateTime.UtcNow, null, "/5 * * ? * *");
var trigger3 = new SimpleTrigger("remotelyAddedTriggerB", "default", "localJob", "default", DateTime.Now, DateTime.Now.AddMinutes(10), SimpleTrigger.RepeatIndefinitely, new TimeSpan(0, 0, 45));
// schedule the job
scheduler.ScheduleJob(job, trigger3);
scheduler.ScheduleJob(job2, trigger2);
scheduler.Start();
Console.WriteLine("Scheduler has been started.");
Console.WriteLine("Press any key to stop scheduler");
Console.ReadKey();
scheduler.Shutdown();
}
示例3: Initialize
/// <summary>
/// Called during creation of the <see cref="IScheduler" /> in order to give
/// the <see cref="ISchedulerPlugin" /> a chance to Initialize.
/// </summary>
public virtual void Initialize(string pluginName, IScheduler scheduler)
{
AppDomain.CurrentDomain.ProcessExit += (sender, ea) =>
{
try
{
scheduler.Shutdown(CleanShutdown);
}
catch (SchedulerException e)
{
}
};
}
示例4: Initialize
/// <summary>
/// Called during creation of the <see cref="IScheduler" /> in order to give
/// the <see cref="ISchedulerPlugin" /> a chance to Initialize.
/// </summary>
public virtual void Initialize(string pluginName, IScheduler scheduler)
{
Log.InfoFormat(CultureInfo.InvariantCulture, "Registering Quartz Shutdown hook '{0}.", pluginName);
AppDomain.CurrentDomain.ProcessExit += (sender, ea) =>
{
Log.Info("Shutting down Quartz...");
try
{
scheduler.Shutdown(CleanShutdown);
}
catch (SchedulerException e)
{
Log.Info("Error shutting down Quartz: " + e.Message, e);
}
};
}
示例5: Initialize
/// <summary>
/// Called during creation of the <see cref="IScheduler" /> in order to give
/// the <see cref="ISchedulerPlugin" /> a chance to Initialize.
/// </summary>
public virtual Task Initialize(string pluginName, IScheduler scheduler)
{
log.InfoFormat("Registering Quartz Shutdown hook '{0}.", pluginName);
AppDomain.CurrentDomain.ProcessExit += (sender, ea) =>
{
log.Info("Shutting down Quartz...");
try
{
scheduler.Shutdown(CleanShutdown);
}
catch (SchedulerException e)
{
log.InfoException("Error shutting down Quartz: " + e.Message, e);
}
};
return TaskUtil.CompletedTask;
}
示例6: Test
//.........这里部分代码省略.........
Assert.That(triggerFromDb.StartTimeOfDay.Second, Is.EqualTo(3));
Assert.That(triggerFromDb.EndTimeOfDay.Hour, Is.EqualTo(2));
Assert.That(triggerFromDb.EndTimeOfDay.Minute, Is.EqualTo(3));
Assert.That(triggerFromDb.EndTimeOfDay.Second, Is.EqualTo(4));
job.RequestsRecovery = (true);
CalendarIntervalTriggerImpl intervalTrigger = new CalendarIntervalTriggerImpl(
"calint_trig_" + count,
schedId,
DateTime.UtcNow.AddMilliseconds(300),
DateTime.UtcNow.AddMinutes(1),
IntervalUnit.Second,
8);
intervalTrigger.JobKey = job.Key;
scheduler.ScheduleJob(intervalTrigger);
// bulk operations
var info = new Dictionary<IJobDetail, Collection.ISet<ITrigger>>();
IJobDetail detail = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
ITrigger simple = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromMilliseconds(4500));
var triggers = new Collection.HashSet<ITrigger>();
triggers.Add(simple);
info[detail] = triggers;
scheduler.ScheduleJobs(info, true);
Assert.IsTrue(scheduler.CheckExists(detail.Key));
Assert.IsTrue(scheduler.CheckExists(simple.Key));
// QRTZNET-243
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("a").DeepClone());
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("a").DeepClone());
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("a").DeepClone());
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("a").DeepClone());
scheduler.Start();
Thread.Sleep(TimeSpan.FromSeconds(3));
scheduler.PauseAll();
scheduler.ResumeAll();
scheduler.PauseJob(new JobKey("job_1", schedId));
scheduler.ResumeJob(new JobKey("job_1", schedId));
scheduler.PauseJobs(GroupMatcher<JobKey>.GroupEquals(schedId));
Thread.Sleep(TimeSpan.FromSeconds(1));
scheduler.ResumeJobs(GroupMatcher<JobKey>.GroupEquals(schedId));
scheduler.PauseTrigger(new TriggerKey("trig_2", schedId));
scheduler.ResumeTrigger(new TriggerKey("trig_2", schedId));
scheduler.PauseTriggers(GroupMatcher<TriggerKey>.GroupEquals(schedId));
Assert.AreEqual(1, scheduler.GetPausedTriggerGroups().Count);
Thread.Sleep(TimeSpan.FromSeconds(3));
scheduler.ResumeTriggers(GroupMatcher<TriggerKey>.GroupEquals(schedId));
Assert.IsNotNull(scheduler.GetTrigger(new TriggerKey("trig_2", schedId)));
Assert.IsNotNull(scheduler.GetJobDetail(new JobKey("job_1", schedId)));
Assert.IsNotNull(scheduler.GetMetaData());
Assert.IsNotNull(scheduler.GetCalendar("weeklyCalendar"));
Thread.Sleep(TimeSpan.FromSeconds(20));
scheduler.Standby();
CollectionAssert.IsNotEmpty(scheduler.GetCalendarNames());
CollectionAssert.IsNotEmpty(scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(schedId)));
CollectionAssert.IsNotEmpty(scheduler.GetTriggersOfJob(new JobKey("job_2", schedId)));
Assert.IsNotNull(scheduler.GetJobDetail(new JobKey("job_2", schedId)));
scheduler.DeleteCalendar("cronCalendar");
scheduler.DeleteCalendar("holidayCalendar");
scheduler.DeleteJob(new JobKey("lonelyJob", "lonelyGroup"));
scheduler.DeleteJob(job.Key);
scheduler.GetJobGroupNames();
scheduler.GetCalendarNames();
scheduler.GetTriggerGroupNames();
}
}
finally
{
scheduler.Shutdown(false);
}
}
示例7: Shutdown
/// <summary>
/// This method places the scheduler in shutdown mode.
/// True - wait for jobs to complete
/// False - immediate shutdown
/// </summary>
/// <param name="qScheduler"></param>
public void Shutdown(IScheduler qScheduler, bool bWait)
{
if (qScheduler.IsStarted)
{
qScheduler.Shutdown(bWait);
}
}
示例8: RunServiceJob
private void RunServiceJob(IServiceJob job, TimeSpan timeout) {
job.ShouldNotBeNull("job");
if(IsDebugEnabled)
log.Debug(@"서비스 작업[{0}]을 실행합니다...", job.Name);
try {
_scheduler = _factory.GetScheduler();
_scheduler.Start();
_scheduler.ScheduleServiceJob(job);
Thread.Sleep(timeout);
}
finally {
_scheduler.Shutdown(true);
if(IsDebugEnabled)
log.Debug(@"서비스 작업[{0}] 실행을 완료했습니다.", job.Name);
}
}