本文整理汇总了C#中Quartz.Impl.StdSchedulerFactory.GetScheduler方法的典型用法代码示例。如果您正苦于以下问题:C# StdSchedulerFactory.GetScheduler方法的具体用法?C# StdSchedulerFactory.GetScheduler怎么用?C# StdSchedulerFactory.GetScheduler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quartz.Impl.StdSchedulerFactory
的用法示例。
在下文中一共展示了StdSchedulerFactory.GetScheduler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuartzService
public QuartzService()
{
InitializeComponent();
logger = LogManager.GetLogger(GetType());
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
scheduler = schedulerFactory.GetScheduler();
}
示例2: Main
static void Main(string[] args)
{
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
IScheduler sched1 = sf.GetScheduler();
JobDetail job = new JobDetail("job1","group1",typeof(SimpleJob));
//DateTime runtime = TriggerUtils.GetEvenMinuteDate(DateTime.UtcNow);//下一分钟
//DateTime runtime = TriggerUtils.GetNextGivenSecondDate(null, 15);//15秒后
//每一秒运行一次 重复十次 开始时间为now 结束时间为null
//SimpleTrigger trigger = new SimpleTrigger("trigger1", "gropp1", "job1", "group1", DateTime.UtcNow, null, 10, TimeSpan.FromSeconds(10));
SimpleTrigger trigger = new SimpleTrigger("trigger1",
"gropp1",
DateTime.UtcNow,
null,
SimpleTrigger.RepeatIndefinitely,
TimeSpan.FromSeconds(1));
sched.ScheduleJob(job,trigger);
LogManager.GetLogger(typeof(Program)).Info("开始循环,每10秒运行一次,重复10次");
sched.Start();
//Thread.Sleep(90 * 1000);
}
示例3: Main
static void Main(string[] args)
{
//Create the scheduler factory
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
//Ask the scheduler factory for a scheduler
IScheduler scheduler = schedulerFactory.GetScheduler();
//Start the scheduler so that it can start executing jobs
scheduler.Start();
// Create a job of Type WriteToConsoleJob
IJobDetail job1 = JobBuilder.Create(typeof(DisallowConcurrentJob)).WithIdentity("DisallowConcurrentJob", "DisallowConcurrentJobGroup").Build();
//Schedule this job to execute every second, a maximum of 10 times
ITrigger trigger1 = TriggerBuilder.Create().WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForTotalCount(10)).StartNow().WithIdentity("DisallowConcurrentJobTrigger", "DisallowConcurrentJobTriggerGroup").Build();
scheduler.ScheduleJob(job1, trigger1);
// Create a job of Type WriteToConsoleJob
IJobDetail job2 = JobBuilder.Create(typeof(AllowConcurrentJob)).WithIdentity("AllowConcurrentJob", "AllowConcurrentJobGroup").Build();
//Schedule this job to execute every second, a maximum of 10 times
ITrigger trigger2 = TriggerBuilder.Create().WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForTotalCount(10)).StartNow().WithIdentity("AllowConcurrentJobTrigger", "AllowConcurrentJobTriggerGroup").Build();
scheduler.ScheduleJob(job2, trigger2);
//Wait for a key press. If we don't wait the program exits and the scheduler gets destroyed
Console.ReadKey();
//A nice way to stop the scheduler, waiting for jobs that are running to finish
scheduler.Shutdown(true);
}
示例4: Run
public void Run()
{
ILog log = LogManager.GetLogger(typeof(SimpleExample));
log.Info("------- Initializing ----------------------");
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
log.Info("------- Initialization Complete -----------");
log.Info("------- Scheduling Jobs -------------------");
DateTime runTime = TriggerUtils.GetEvenMinuteDate(DateTime.UtcNow);
JobDetail job = new JobDetail("job1", "group1", typeof(HelloJob));
SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", runTime);
sched.ScheduleJob(job, trigger);
sched.Start();
log.Info("------- Started Scheduler -----------------");
// wait long enough so that the scheduler as an opportunity to
// run the job!
log.Info("------- Waiting 90 seconds... -------------");
// wait 90 seconds to show jobs
Thread.Sleep(90 * 1000);
// shut down the scheduler
log.Info("------- Shutting Down ---------------------");
sched.Shutdown(true);
log.Info("------- Shutdown Complete -----------------");
}
示例5: Start
static void Start(IAppBuilder app) {
// First, initialize Quartz.NET as usual. In this sample app I'll configure Quartz.NET by code.
var schedulerFactory = new StdSchedulerFactory();
var scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
// I'll add some global listeners
//scheduler.ListenerManager.AddJobListener(new GlobalJobListener());
//scheduler.ListenerManager.AddTriggerListener(new GlobalTriggerListener());
// A sample trigger and job
var trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger")
.WithSchedule(DailyTimeIntervalScheduleBuilder.Create()
.WithIntervalInSeconds(6))
.StartNow()
.Build();
var job = new JobDetailImpl("myJob", null, typeof(HelloJob));
scheduler.ScheduleJob(job, trigger);
// A cron trigger and job
var cron = TriggerBuilder.Create()
.WithIdentity("myCronTrigger")
.ForJob(job.Key)
.WithCronSchedule("0/10 * * * * ?") // every 10 seconds
.Build();
scheduler.ScheduleJob(cron);
// A dummy calendar
//scheduler.AddCalendar("myCalendar", new DummyCalendar { Description = "dummy calendar" }, false, false);
app.Use(QuartzNetWebConsole.Setup.Owin("/quartz/", () => scheduler));
}
示例6: JobSchedule
public JobSchedule()
{
var schedFact = new StdSchedulerFactory();
sched = schedFact.GetScheduler();
sched.Start();
}
示例7: OnStart
protected override void OnStart(string[] args)
{
using (System.IO.StreamWriter sw = new System.IO.StreamWriter("E:\\log.txt", true))
{
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "start.");
}
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<HelloWorld>()
.WithIdentity("myJob", "group1")
.Build();
//ITrigger trigger = TriggerBuilder.Create()
// .WithIdentity("myTrigger", "group1")
// .StartNow()
// .WithSimpleSchedule(x => x
// .WithIntervalInHours(1)
// .RepeatForever())
// .Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger", "group1")
.WithCronSchedule("0/5 * * * * ?")
.ForJob("myJob", "group1")
.Build();
sched.ScheduleJob(job, trigger);
}
示例8: Main
static void Main(string[] args)
{
var factory = new StdSchedulerFactory();
var scheduler = factory.GetScheduler();
scheduler.Start();
while (!scheduler.IsStarted)
{
Console.WriteLine("Waiting for scheduler to start.");
Thread.Sleep(1000);
}
Console.WriteLine("IsStarted={0}", scheduler.IsStarted);
Console.WriteLine("SchedulerInstanceId={0}", scheduler.SchedulerInstanceId);
Console.WriteLine("SchedulerName={0}", scheduler.SchedulerName);
Console.WriteLine("The scheduler is running. Press any key to stop");
Console.ReadKey();
Console.WriteLine("Shutting down scheduler");
scheduler.Shutdown(false);
while (!scheduler.IsShutdown)
{
Console.WriteLine("Waiting for scheduler to shutdown.");
Thread.Sleep(1000);
}
Console.WriteLine("IsShutdown={0}", scheduler.IsShutdown);
Console.WriteLine("The scheduler has been shutdown.");
}
示例9: OnStart
protected override void OnStart(string[] args)
{
logger.Log(LogLevel.Info, String.Format("Starting Open Payments Processor"));
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
IScheduler sched = schedFact.GetScheduler();
Context ctx = new Context();
JobDetail jobDetail = new JobDetail("myJob", null, typeof(ProcessOpenPaymentJob));
Trigger trigger = TriggerUtils.MakeDailyTrigger(5, 00);
trigger.StartTimeUtc = DateTime.UtcNow;
trigger.Name = "myTrigger1";
sched.ScheduleJob(jobDetail, trigger);
try
{
logger.Log(LogLevel.Info, String.Format("Starting Scheduler"));
sched.Start();
}
catch (Exception ex)
{
logger.Log(LogLevel.Info, String.Format("Exception Starting Scheduler {0}", ex.Message));
throw;
}
}
示例10: DoHelloWorld
public string DoHelloWorld()
{
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("myJob", "group1")
.Build();
// Trigger the job to run now, and then every 40 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(5)
.RepeatForever())
.Build();
sched.ScheduleJob(job, trigger);
return "NOOOOO, they're all gonna laugh at you!";
}
示例11: Main
static void Main(string[] args)
{
try
{
Console.Title = "QMail";
Console.ForegroundColor = ConsoleColor.White;
ISchedulerFactory sf = new StdSchedulerFactory();
Scheduler = sf.GetScheduler();
new TskInspectDetailJobTrigger();
Scheduler.Start();
for (var i = 0; i < 10; i++) {
Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(" ---------------------------------------------------");
Console.WriteLine(" ...................QMail已启动......................");
Console.WriteLine(" ...................请不要关闭此窗口.................");
Console.WriteLine(" ---------------------------------------------------");
for (var i = 0; i < 10; i++)
{
Console.WriteLine();
}
Console.ReadLine();
}
catch (Exception e) {
LogUtil.Logger.Error(e.Message);
}
}
示例12: InitScheduler
public static void InitScheduler(String link)
{
if (rootPath != null)
return;
rootPath = link;
ISchedulerFactory schedFact = new StdSchedulerFactory();
Scheduler = schedFact.GetScheduler();
Scheduler.Start();
IJobDetail jobDetail = JobBuilder.Create<PhotoNotifyJob>().WithIdentity("PhotoNotificationJob").Build();
jobDetail.JobDataMap.Add("path", rootPath);
//Wystartuj jak najwczesniej, o godzinie 2:00 rano
DateTime startAt = DateTime.Today;
startAt = startAt.AddHours(2);
if (startAt < DateTime.Now) //jesli juz minela godzina 2, wystartuj nastepnego dnia
startAt = startAt.AddDays(1);
ITrigger trigger2 = (ISimpleTrigger)TriggerBuilder.Create()
.WithIdentity("trigger")
.StartAt(startAt) // wystartuj scheduler o zadanej godzinie
.WithSimpleSchedule(x => x.WithIntervalInHours(24).RepeatForever()) //odpalaj notyfikacje co 24h, bez limitu powtorzen
.Build();
DateTimeOffset ft = Scheduler.ScheduleJob(jobDetail, trigger2);
System.Diagnostics.Debug.WriteLine(jobDetail.Key + " has been scheduled to run at: " + ft);
}
示例13: StartSample
public void StartSample()
{
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// define the job and tie it to our HelloJob class
JobDataMap newJobDataMap = new JobDataMap {{"myStateData", new List<DateTimeOffset>()}};
IJobDetail job = JobBuilder.Create<StateJob>()
.WithIdentity("myJob", "group1")
.SetJobData(newJobDataMap)
.Build();
// Trigger the job to run now, and then every 5 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(5)
.RepeatForever())
.Build();
sched.ScheduleJob(job, trigger);
}
示例14: Scheduler
private Scheduler()
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
this._sched = schedFact.GetScheduler();
// Start up the scheduler (nothing can actually run until the scheduler has been started)
this._sched.Start();
}
示例15: TestMethod1
public void TestMethod1()
{
XmlConfigurator.Configure();
log.Info("------- Initializing ----------------------");
// First we must get a reference to a scheduler
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sched = sf.GetScheduler();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<MyJob>()
.WithIdentity("MyJob")
.Build();
// Trigger the job to run on the next round minute
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("MyTrigger")
.WithCronSchedule("0 0/5 * * * ?")
.Build();
// Tell quartz to schedule the job using our trigger
sched.ScheduleJob(job, trigger);
// Start up the scheduler (nothing can actually run until the
// scheduler has been started)
sched.Start();
sched.Shutdown();
Thread.Sleep(300 * 1000);
}