当前位置: 首页>>代码示例>>C#>>正文


C# StdSchedulerFactory.Start方法代码示例

本文整理汇总了C#中Quartz.Impl.StdSchedulerFactory.Start方法的典型用法代码示例。如果您正苦于以下问题:C# StdSchedulerFactory.Start方法的具体用法?C# StdSchedulerFactory.Start怎么用?C# StdSchedulerFactory.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quartz.Impl.StdSchedulerFactory的用法示例。


在下文中一共展示了StdSchedulerFactory.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestTriggerFinalized

        public void TestTriggerFinalized()
        {
            Qtz205TriggerListener triggerListener = new Qtz205TriggerListener();
            Qtz205ScheListener schedulerListener = new Qtz205ScheListener();
            NameValueCollection props = new NameValueCollection();
            props["quartz.scheduler.idleWaitTime"] = "1500";
            props["quartz.threadPool.threadCount"] = "2";
            IScheduler scheduler = new StdSchedulerFactory(props).GetScheduler();
            scheduler.ListenerManager.AddSchedulerListener(schedulerListener);
            scheduler.ListenerManager.AddTriggerListener(triggerListener);

            IJobDetail job = JobBuilder.Create<Qtz205Job>().WithIdentity("test").Build();
            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity("test")
                .WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForTotalCount(3))
                .Build();

            scheduler.ScheduleJob(job, trigger);
            scheduler.Start();
            Thread.Sleep(5000);

            scheduler.Shutdown(true);

            Assert.AreEqual(2, jobExecutionCount);
            Assert.AreEqual(3, triggerListener.FireCount);
            Assert.AreEqual(1, schedulerListener.TriggerFinalizedCount);
        }
开发者ID:vaskosound,项目名称:FantasyLeagueStats,代码行数:27,代码来源:SchedulerListenerTest.cs

示例2: OnStart

        public override bool OnStart()
        {
            Trace.WriteLine("WorkerRole1 Run", "Information");

            var properties = new NameValueCollection();
            properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
            properties["quartz.jobStore.dataSource"] = "default";
            properties["quartz.jobStore.clustered"] = "true";
            properties["quartz.jobStore.selectWithLockSQL"] = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM {0}{1} WHERE {2} = {3} AND {4} = @lockName", new object[] { "{0}", "LOCKS", "SCHED_NAME", "{1}", "LOCK_NAME" });
            properties["quartz.jobStore.acquireTriggersWithinLock"] = "true";
            properties["quartz.scheduler.instanceId"] = "AUTO";
            properties["quartz.threadPool.threadCount"] = "1";
            properties["quartz.jobStore.tablePrefix"] = "Scheduling.";
            properties["quartz.dataSource.default.connectionString"] = @"Server = (local)\sqlexpress; Database = DB; Integrated Security = True";
            properties["quartz.dataSource.default.provider"] = "SqlServer-20";

            var scheduler = new StdSchedulerFactory(properties).GetScheduler();
            scheduler.Clear();

            var triggerKey = new TriggerKey("t1");
            var trigger = scheduler.GetTrigger(triggerKey);

            var jobBuilder = JobBuilder.Create<Job>();
            var job = jobBuilder.Build();

            var t = scheduler.GetTrigger(new TriggerKey("t1"));

            trigger = new SimpleTriggerImpl("t1", 100000, TimeSpan.FromSeconds(5));

            scheduler.ScheduleJob(job, trigger);

            scheduler.Start();

            return base.OnStart();
        }
开发者ID:peterhholroyd,项目名称:fmg_dhc,代码行数:35,代码来源:WorkerRole.cs

示例3: Main

        static void Main(string[] args)
        {
            var scheduler = new StdSchedulerFactory().GetScheduler();

            // add scheduler listener
            scheduler.ListenerManager.AddSchedulerListener(new SchedulerListener());

            // add global job listener
            scheduler.ListenerManager.AddJobListener(new JobListener(), GroupMatcher<JobKey>.AnyGroup());

            // add global trigger listener
            scheduler.ListenerManager.AddTriggerListener(new TriggerListener(), GroupMatcher<TriggerKey>.AnyGroup());

            // add jobs & triggers
            scheduler.ScheduleJob(
                JobBuilder.Create<ExampleJob>().WithIdentity("MyJob", "MyJobGroup").Build(),
                TriggerBuilder.Create().WithIdentity("MyTrigger", "MyTriggerGroup")
                    .WithSimpleSchedule(s => s.WithIntervalInSeconds(2).RepeatForever()).Build());

            scheduler.Start(); // start scheduler
            Thread.Sleep(5000); // sleep the main thread (Quartz will fire the job 3x on other threads)
            scheduler.Shutdown(true); // stop the scheduler

            Console.ReadLine();
        }
开发者ID:cknightdevelopment,项目名称:CodeIn60Seconds,代码行数:25,代码来源:Program.cs

示例4: TestNoConcurrentExecOnSameJobWithBatching

        public void TestNoConcurrentExecOnSameJobWithBatching()
        {
            DateTime startTime = DateTime.Now.AddMilliseconds(300).ToUniversalTime(); // make the triggers fire at the same time.

            IJobDetail job1 = JobBuilder.Create<TestJob>().WithIdentity("job1").Build();
            ITrigger trigger1 = TriggerBuilder.Create().WithSimpleSchedule().StartAt(startTime).Build();

            ITrigger trigger2 = TriggerBuilder.Create().WithSimpleSchedule().StartAt(startTime).ForJob(job1).Build();

            NameValueCollection props = new NameValueCollection();
            props["quartz.scheduler.idleWaitTime"] = "1500";
            props["quartz.scheduler.batchTriggerAcquisitionMaxCount"] = "2";
            props["quartz.threadPool.threadCount"] = "2";
            IScheduler scheduler = new StdSchedulerFactory(props).GetScheduler();
            scheduler.ListenerManager.AddJobListener(new TestJobListener(2));
            scheduler.ScheduleJob(job1, trigger1);
            scheduler.ScheduleJob(trigger2);

            scheduler.Start();
            barrier.WaitOne();
            scheduler.Shutdown(true);

            Assert.AreEqual(2, jobExecDates.Count);
            Assert.Greater(jobExecDates[1] - jobExecDates[0], jobBlockTime);
        }
开发者ID:vaskosound,项目名称:FantasyLeagueStats,代码行数:25,代码来源:DisallowConcurrentJobExecutionTest.cs

示例5: TestSameDefaultPriority

		public void TestSameDefaultPriority()
		{
            NameValueCollection config = new NameValueCollection();
		    config["quartz.threadPool.threadCount"] = "1";
		    config["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool";

            IScheduler sched = new StdSchedulerFactory(config).GetScheduler();
            
			DateTime n = DateTime.UtcNow;
			DateTime cal = new DateTime(n.Year, n.Month, n.Day, n.Hour, n.Minute, 1, n.Millisecond);

            IMutableTrigger trig1 = new SimpleTriggerImpl("T1", null, cal);
            IMutableTrigger trig2 = new SimpleTriggerImpl("T2", null, cal);

			JobDetailImpl jobDetail = new JobDetailImpl("JD", null, typeof (TestJob));

			sched.ScheduleJob(jobDetail, trig1);

			trig2.JobKey = new JobKey(jobDetail.Key.Name);
			sched.ScheduleJob(trig2);

			sched.Start();

			Thread.Sleep(2000);

			Assert.AreEqual("T1T2", result.ToString());

			sched.Shutdown();
		}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:29,代码来源:PriorityTest.cs

示例6: PauseScheduler

        public virtual void PauseScheduler()
        {
            IScheduler sched = null;

            "Given a scheduler that is started".Given(() =>
            {//arrange
                sched = new StdSchedulerFactory(_props).GetScheduler();
                sched.Start();
            });

            "When calling pause all".When(() =>
            {//act
                sched.PauseAll();
                sched.GetDescription().LogMe(LogLevel.Debug);
            });

            "Then ".Then(() =>
            {
                sched.IsStarted.Should().BeTrue("it is still running.");

                var groupNames = sched.GetJobGroupNames();
                if (groupNames.Count == 0) Log.Info("No job groups found to pause.");
                foreach (var groupName in groupNames)
                {
                    Log.InfoFormat("GroupName = {0}", groupName);
                    sched.IsJobGroupPaused(groupName).Should().BeTrue("pause all should pause all job groups");
                }
            });
        }
开发者ID:dzstoever,项目名称:ZenFacades,代码行数:29,代码来源:LocalSchedulerScenarios.cs

示例7: Main

        static void Main(string[] args)
        {
            var settings = SettingsFactory.Create<PingerSettings>(ConfigurationManager.AppSettings["settings"]);

            if(settings != null && settings.Pings != null && settings.Pings.Count > 0)
            {
                // construct a scheduler
                var scheduler = new StdSchedulerFactory().GetScheduler();
                scheduler.Start();

                settings.Pings.ForEach(p=>
                {
                    var job = JobBuilder.Create<Pinger>()
                        .UsingJobData("urls",string.Join(",",p.Urls))
                        .Build();

                    var trigger = TriggerBuilder.Create()
                                    .WithSimpleSchedule(x =>
                                    x.WithInterval(TimeSpan.FromMinutes(p.Interval)).RepeatForever())
                                    .Build();

                    scheduler.ScheduleJob(job, trigger);
                });
            }
        }
开发者ID:thatandyrose,项目名称:appharbor-workers,代码行数:25,代码来源:Program.cs

示例8: SetupIndexingSchedule

 static IScheduler SetupIndexingSchedule()
 {
     var scheduler = new StdSchedulerFactory().GetScheduler();
     scheduler.Start();
     var job = JobBuilder.Create<IndexAgent>().WithIdentity("Indexer").Build();
     var trigger = TriggerBuilder.Create()
         .StartNow()
         .WithSimpleSchedule(x => x.WithIntervalInHours(1).RepeatForever())
         .Build();
     scheduler.ScheduleJob(job, trigger);
     return scheduler;
 }
开发者ID:kevintavog,项目名称:FIndAPhoto-2.net,代码行数:12,代码来源:Startup.cs

示例9: OnStart

        public override bool OnStart()
        {
            CrashingWorker.xx += WorkerRole_xx;

            Trace.WriteLine("WorkerRole1 Run", "Information");

            var properties = new NameValueCollection(ConfigurationManager.GetSection("quartz") as NameValueCollection);
            var c = string.Join(".", new string[] { StdSchedulerFactory.PropertyDataSourcePrefix, properties["quartz.jobStore.dataSource"], StdSchedulerFactory.PropertyDataSourceConnectionString });

            properties[c] = Database.SchedulerConnection;

            var scheduler = new StdSchedulerFactory(properties).GetScheduler();

            scheduler.Start();

            return base.OnStart();
        }
开发者ID:peterhholroyd,项目名称:fmg_dhc,代码行数:17,代码来源:CrashingWorkerTest.cs

示例10: TestJobInterruption

        public void TestJobInterruption()
        {
            // create a simple scheduler

            NameValueCollection config = new NameValueCollection();
            config["quartz.scheduler.instanceName"] = "InterruptableJobTest_Scheduler";
            config["quartz.scheduler.instanceId"] = "AUTO";
            config["quartz.threadPool.threadCount"] = "2";
            config["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool";
            IScheduler sched = new StdSchedulerFactory(config).GetScheduler();
            sched.Start();

            // add a job with a trigger that will fire immediately

            IJobDetail job = JobBuilder.Create<TestInterruptableJob>()
                .WithIdentity("j1")
                .Build();

            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity("t1")
                .ForJob(job)
                .StartNow()
                .Build();

            sched.ScheduleJob(job, trigger);

            sync.WaitOne(); // make sure the job starts running...

            IList<IJobExecutionContext> executingJobs = sched.GetCurrentlyExecutingJobs();

            Assert.AreEqual(1, executingJobs.Count, "Number of executing jobs should be 1 ");

            IJobExecutionContext jec = executingJobs[0];

            bool interruptResult = sched.Interrupt(jec.FireInstanceId);

            sync.WaitOne(); // wait for the job to terminate

            Assert.IsTrue(interruptResult, "Expected successful result from interruption of job ");
            Assert.IsTrue(TestInterruptableJob.interrupted, "Expected interrupted flag to be set on job class ");

            sched.Clear();
            sched.Shutdown();
        }
开发者ID:vaskosound,项目名称:FantasyLeagueStats,代码行数:44,代码来源:InterrubtableJobTest.cs

示例11: Main

        static void Main(string[] args)
        {
            var properties = new NameValueCollection();
            properties["quartz.threadPool.threadCount"] = "1";
            
            const string cronExpression = "0/30 * * * * ?";

            var scheduler = new StdSchedulerFactory(properties).GetScheduler();
            
            var job = new JobDetail("NomeJob", "GrupoJob", typeof(BillingJob));

            var trigger = new CronTrigger("NomeTrigger", "GrupoTrigger", "NomeJob", "GrupoJob", cronExpression);

            scheduler.ScheduleJob(job, trigger);

            scheduler.Start();

            Console.ReadKey();

            scheduler.Shutdown();
        }
开发者ID:alpsantos,项目名称:Quartz.Net-Example,代码行数:21,代码来源:Program.cs

示例12: Main

        static void Main(string[] args)
        {
            //ScheduledJob.Run();
            // TODO: Initialiaze Scheduler
            var scheduler = new StdSchedulerFactory().GetScheduler();
            scheduler.Start();

            var jobDetail = JobBuilder.Create<ExampleJob>()
                .WithIdentity(new JobKey("ExampleJob"))
                .Build();
            jobDetail.JobDataMap.Put("DataKey", "Passed value");
            jobDetail.JobDataMap.Put("FilePath", ConfigurationManager.AppSettings["FilePath"] as string);

            // Let's create a trigger that fires immediately
            ICronTrigger trigger = TriggerBuilder.Create()
                                                 .WithIdentity("WriteHelloToLog", "IT")
                                                 .WithCronSchedule("0 0/1 * 1/1 * ? *") //-> visit http://www.cronmaker.com/ Queues the job every minute
                                                 .StartAt(DateTime.UtcNow)
                                                 .WithPriority(1)
                                                 .Build() as ICronTrigger;

            ITrigger dailyTrigger = TriggerBuilder.Create()
                                      .WithDailyTimeIntervalSchedule(schedBuilder => schedBuilder
                                          .WithIntervalInMinutes(30)
                                          .OnDaysOfTheWeek(new[] {
                                                          DayOfWeek.Monday,
                                                          DayOfWeek.Tuesday,
                                                          DayOfWeek.Wednesday,
                                                          DayOfWeek.Thursday,
                                                          DayOfWeek.Friday })
                                          .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(9, 30))
                                          .EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(19, 30)))
                                      .Build();

            scheduler.ScheduleJob(jobDetail, trigger);

            scheduler.TriggerJob(new JobKey("ExampleJob"));
        }
开发者ID:devworker55,项目名称:SourceLab,代码行数:38,代码来源:Program.cs

示例13: StartCronJobs

        private void StartCronJobs()
        {
            IScheduler sched;
            IJobDetail jobDetail;
            ITrigger trigger;

            var cronJobs = new r3mus_DBEntities().CRONJobs; //.Where(cronJob => cronJob.Enabled == true);

            cronJobs.ToList().ForEach(cronJob =>
            {
                sched = new StdSchedulerFactory().GetScheduler();
                sched.Start();

                jobDetail = JobBuilder.Create(Type.GetType(string.Concat("r3mus.CRONJobs.", cronJob.JobName)))
                    .WithIdentity(string.Format("{0}Instance", cronJob.JobName), string.Format("{0}Group", cronJob.JobName))
                    .Build();
                trigger = TriggerBuilder.Create()
                    .WithIdentity(string.Format("{0}Trigger", cronJob.JobName), string.Format("{0}TriggerGroup", cronJob.JobName))
                    .StartNow()
                    .WithSimpleSchedule(x => x.WithIntervalInMinutes(cronJob.Schedule).RepeatForever())
                    .Build();
                sched.ScheduleJob(jobDetail, trigger);
            });

            sched = new StdSchedulerFactory().GetScheduler();
            sched.Start();

            //jobDetail = JobBuilder.Create(Type.GetType("r3mus.CRONJobs.PreloadInfo"))
            //    .WithIdentity("PreloadInfoInstance", "PreloadInfoGroup")
            //    .Build();
            //trigger = TriggerBuilder.Create()
            //    .WithIdentity("PreloadInfoTrigger", "PreloadInfoTriggerGroup")
            //    .StartNow()
            //    .WithSimpleSchedule(x => x.WithIntervalInMinutes(15).RepeatForever())
            //    .Build();
            //sched.ScheduleJob(jobDetail, trigger);
        }
开发者ID:R3MUSDevPack,项目名称:ReconnectedServerStuff,代码行数:37,代码来源:Global.asax.cs

示例14: OnStart

        protected override void OnStart(string[] args)
        {
            //ScheduledJob.Run();
            // TODO Initialiaze Scheduler
            var scheduler = new StdSchedulerFactory().GetScheduler();
            scheduler.Start();

            var jobDetail = JobBuilder.Create<HelloWorldJob>()
                .WithIdentity(new JobKey("HelloWorldJob"))
                .Build();
            jobDetail.JobDataMap.Put("DataKey", "Passed value");
            jobDetail.JobDataMap.Put("FilePath", System.Configuration.ConfigurationManager.AppSettings["FilePath"] as string);

            // Let's create a trigger that fires immediately
            var trigger = (ICronTrigger)TriggerBuilder.Create()
                .WithIdentity("WriteHelloToLog", "IT")
                .WithCronSchedule("0 0/1 * 1/1 * ? *") // visit http://www.cronmaker.com/ Queues the job every minute
                .StartAt(DateTime.UtcNow)
                .WithPriority(1)
                .Build();
            scheduler.ScheduleJob(jobDetail, trigger);

            scheduler.TriggerJob(new JobKey("HelloWorldJob"));
        }
开发者ID:modulexcite,项目名称:QuartzOnWindowsService,代码行数:24,代码来源:Service1.cs

示例15: ShutdownScheduler

        public virtual void ShutdownScheduler()
        {
            IScheduler sched = null;

            "Given a scheduler that is started".Given(() =>
            {//arrange
                sched = new StdSchedulerFactory(_props).GetScheduler();
                sched.Start();
            });

            "When calling shutdown".When(() =>
            {//act
                sched.Shutdown();
                sched.GetDescription().LogMe(LogLevel.Debug);
            });

            "Then ".Then(() => sched.IsShutdown.Should().BeTrue("it is shutdown"));
            //Note: IsStarted, and InStandbyMode are also true.
        }
开发者ID:dzstoever,项目名称:ZenFacades,代码行数:19,代码来源:LocalSchedulerScenarios.cs


注:本文中的Quartz.Impl.StdSchedulerFactory.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。