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


C# StdSchedulerFactory.Shutdown方法代码示例

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


在下文中一共展示了StdSchedulerFactory.Shutdown方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例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: 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

示例5: Should_be_possible_to_schedule_a_request_collect_in_specific_date

 public void Should_be_possible_to_schedule_a_request_collect_in_specific_date()
 {
     var collectRequest = new CollectRequestFactory().CreateCollectRequest(DataProvider.GetSession()).Item2;
     var scheduleInformation = new ScheduleInformation() { ScheduleDate = DateTime.Now.AddSeconds(1) };
     var scheduler = new StdSchedulerFactory().GetScheduler();
     var scheduleController = new ScheduleController(scheduler) { TypeOfExecutionJob = typeof(TestJob) };
     
     scheduleController.ScheduleCollection(collectRequest.Oid.ToString(), "", scheduleInformation.ScheduleDate);
     
     Assert.AreEqual(1, scheduleController.GetNumberOfCollectRequestScheduled());
     scheduler.Shutdown();
 }
开发者ID:jonaslsl,项目名称:modSIC,代码行数:12,代码来源:SchedulerControllerTest.cs

示例6: 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

示例7: Should_be_possible_to_reschedule_the_collectRequest_that_was_not_collect

        public void Should_be_possible_to_reschedule_the_collectRequest_that_was_not_collect()
        {
            var fakeSession = DataProvider.GetSession();
            var package1 = new CollectRequestFactory().CreateCollectRequest(fakeSession);
            var collectRequest = package1.Item2;
            this.SaveCollectRequest(collectRequest);
            var package2 = new CollectRequestFactory().CreateCollectRequest(fakeSession);
            var otherCollectRequest = package2.Item2;
            this.SaveCollectRequest(otherCollectRequest);
            package1.Item1.ScheduleInformation.ExecutionDate.AddSeconds(100);
            package2.Item1.ScheduleInformation.ExecutionDate.AddSeconds(100);
            var fakeRepository = new CollectRequestRepository(DataProvider);
            var scheduler = new StdSchedulerFactory().GetScheduler();
            var scheduleController = new ScheduleController(scheduler);
            scheduleController.TypeOfExecutionJob = typeof(TestJob);

            scheduleController.ReScheduleCollectRequests(
                fakeSession,
                new[] { collectRequest, otherCollectRequest },
                fakeRepository);

            Assert.AreEqual(2, scheduleController.GetNumberOfCollectRequestScheduled(), "the number of collectRequest schedule is not expected");
            scheduler.Shutdown();
        }
开发者ID:ywcsz,项目名称:modSIC,代码行数:24,代码来源:SchedulerControllerTest.cs

示例8: Should_be_possible_get_the_collectRequestIds_that_are_executing_in_the_scheduler

        public void Should_be_possible_get_the_collectRequestIds_that_are_executing_in_the_scheduler()
        {
            var collectRequest = new CollectRequestFactory().CreateCollectRequest(DataProvider.GetSession()).Item2;
            var scheduleInformation = new ScheduleInformation() { ScheduleDate = DateTime.Now.AddSeconds(1) };
            this.SaveCollectRequest(collectRequest);
            var scheduler = new StdSchedulerFactory().GetScheduler();
            var scheduleController = new ScheduleController(scheduler) { TypeOfExecutionJob = typeof(TestJob) };

            scheduleController.ScheduleCollection(collectRequest.Oid.ToString(), "", scheduleInformation.ScheduleDate);
            Thread.Sleep(1000);

            var collectRequestIds = scheduleController.GetCollectRequestIdRunning();
            Assert.IsTrue(collectRequestIds.Count() > 0);
            scheduler.Shutdown();
        }
开发者ID:ywcsz,项目名称:modSIC,代码行数:15,代码来源:SchedulerControllerTest.cs

示例9: Should_not_possible_schedule_the_collectRequest_if_already_exists_a_job_defined

        public void Should_not_possible_schedule_the_collectRequest_if_already_exists_a_job_defined()
        {
            var scheduleInformation = new ScheduleInformation() { ScheduleDate = DateTime.Now.AddSeconds(1) };
            var collectRequest = new CollectRequestFactory().CreateCollectRequest(DataProvider.GetSession()).Item2;
            this.SaveCollectRequest(collectRequest);
            var scheduler = new StdSchedulerFactory().GetScheduler();
            var scheduleController = new ScheduleController(scheduler) { TypeOfExecutionJob = typeof(TestJob) };
            var collectRequestId = collectRequest.Oid.ToString();

            scheduleController.ScheduleCollection(collectRequestId, "", scheduleInformation.ScheduleDate);
            scheduleController.ScheduleCollection(collectRequestId, "", scheduleInformation.ScheduleDate);

            Assert.AreEqual(1, scheduleController.GetNumberOfCollectRequestScheduled());
            scheduler.Shutdown();
        }
开发者ID:ywcsz,项目名称:modSIC,代码行数:15,代码来源:SchedulerControllerTest.cs

示例10: TestBasicStorageFunctions


//.........这里部分代码省略.........
                                    .WithIdentity("t3", "g1")
                                    .ForJob(job)
                                    .StartNow()
                                    .WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(5))
                                    .Build();

            sched.ScheduleJob(job, trigger);


            IList<string> jobGroups = sched.GetJobGroupNames();
            IList<string> triggerGroups = sched.GetTriggerGroupNames();

            Assert.AreEqual(2, jobGroups.Count, "Job group list size expected to be = 2 ");
            Assert.AreEqual(2, triggerGroups.Count, "Trigger group list size expected to be = 2 ");

            Collection.ISet<JobKey> jobKeys = sched.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(JobKey.DefaultGroup));
            Collection.ISet<TriggerKey> triggerKeys = sched.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals(TriggerKey.DefaultGroup));

            Assert.AreEqual(1, jobKeys.Count, "Number of jobs expected in default group was 1 ");
            Assert.AreEqual(1, triggerKeys.Count, "Number of triggers expected in default group was 1 ");

            jobKeys = sched.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("g1"));
            triggerKeys = sched.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("g1"));

            Assert.AreEqual(2, jobKeys.Count, "Number of jobs expected in 'g1' group was 2 ");
            Assert.AreEqual(2, triggerKeys.Count, "Number of triggers expected in 'g1' group was 2 ");


            TriggerState s = sched.GetTriggerState(new TriggerKey("t2", "g1"));
            Assert.AreEqual(TriggerState.Normal, s, "State of trigger t2 expected to be NORMAL ");

            sched.PauseTrigger(new TriggerKey("t2", "g1"));
            s = sched.GetTriggerState(new TriggerKey("t2", "g1"));
            Assert.AreEqual(TriggerState.Paused, s, "State of trigger t2 expected to be PAUSED ");

            sched.ResumeTrigger(new TriggerKey("t2", "g1"));
            s = sched.GetTriggerState(new TriggerKey("t2", "g1"));
            Assert.AreEqual(TriggerState.Normal, s, "State of trigger t2 expected to be NORMAL ");

            Collection.ISet<string> pausedGroups = sched.GetPausedTriggerGroups();
            Assert.AreEqual(0, pausedGroups.Count, "Size of paused trigger groups list expected to be 0 ");

            sched.PauseTriggers(GroupMatcher<TriggerKey>.GroupEquals("g1"));

            // test that adding a trigger to a paused group causes the new trigger to be paused also... 
            job = JobBuilder.Create()
                            .OfType<TestJob>()
                            .WithIdentity("j4", "g1")
                            .Build();

            trigger = TriggerBuilder.Create()
                                    .WithIdentity("t4", "g1")
                                    .ForJob(job)
                                    .StartNow()
                                    .WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(5))
                                    .Build();

            sched.ScheduleJob(job, trigger);

            pausedGroups = sched.GetPausedTriggerGroups();
            Assert.AreEqual(1, pausedGroups.Count, "Size of paused trigger groups list expected to be 1 ");

            s = sched.GetTriggerState(new TriggerKey("t2", "g1"));
            Assert.AreEqual(TriggerState.Paused, s, "State of trigger t2 expected to be PAUSED ");

            s = sched.GetTriggerState(new TriggerKey("t4", "g1"));
            Assert.AreEqual(TriggerState.Paused, s, "State of trigger t4 expected to be PAUSED");

            sched.ResumeTriggers(GroupMatcher<TriggerKey>.GroupEquals("g1"));

            s = sched.GetTriggerState(new TriggerKey("t2", "g1"));
            Assert.AreEqual(TriggerState.Normal, s, "State of trigger t2 expected to be NORMAL ");

            s = sched.GetTriggerState(new TriggerKey("t4", "g1"));
            Assert.AreEqual(TriggerState.Normal, s, "State of trigger t2 expected to be NORMAL ");

            pausedGroups = sched.GetPausedTriggerGroups();
            Assert.AreEqual(0, pausedGroups.Count, "Size of paused trigger groups list expected to be 0 ");


            Assert.IsFalse(sched.UnscheduleJob(new TriggerKey("foasldfksajdflk")), "Scheduler should have returned 'false' from attempt to unschedule non-existing trigger. ");

            Assert.IsTrue(sched.UnscheduleJob(new TriggerKey("t3", "g1")), "Scheduler should have returned 'true' from attempt to unschedule existing trigger. ");

            jobKeys = sched.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("g1"));
            triggerKeys = sched.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("g1"));

            Assert.AreEqual(2, jobKeys.Count, "Number of jobs expected in 'g1' group was 1 "); // job should have been deleted also, because it is non-durable
            Assert.AreEqual(2, triggerKeys.Count, "Number of triggers expected in 'g1' group was 1 ");

            Assert.IsTrue(sched.UnscheduleJob(new TriggerKey("t1")), "Scheduler should have returned 'true' from attempt to unschedule existing trigger. ");

            jobKeys = sched.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(JobKey.DefaultGroup));
            triggerKeys = sched.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals(TriggerKey.DefaultGroup));

            Assert.AreEqual(1, jobKeys.Count, "Number of jobs expected in default group was 1 "); // job should have been left in place, because it is non-durable
            Assert.AreEqual(0, triggerKeys.Count, "Number of triggers expected in default group was 0 ");

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

示例11: Execute

        /// <summary>
        /// Executes this instance.
        /// </summary>
        public void Execute()
        {
            using ( var rockContext = new RockContext() )
            {
                var jobService = new ServiceJobService( rockContext );

                ServiceJob job = jobService.Get( JobId );
                if ( job != null )
                {
                    try
                    {
                        // create a scheduler
                        var scheduleConfig = new System.Collections.Specialized.NameValueCollection();
                        scheduleConfig.Add( "org.quartz.scheduler.instanceName", "RunNow" );
                        var sched = new StdSchedulerFactory( scheduleConfig ).GetScheduler();

                        // create the quartz job and trigger
                        IJobDetail jobDetail = jobService.BuildQuartzJob( job );
                        var jobTrigger = TriggerBuilder.Create()
                            .WithIdentity( job.Guid.ToString(), job.Name )
                            .StartNow()
                            .Build();

                        // schedule the job
                        sched.ScheduleJob( jobDetail, jobTrigger );

                        // set up the listener to report back from the job when it completes
                        sched.ListenerManager.AddJobListener( new RockJobListener(), EverythingMatcher<JobKey>.AllJobs() );

                        // start the scheduler
                        sched.Start();

                        // Wait 10secs to give job chance to start
                        Thread.Sleep( new TimeSpan( 0, 0, 10 ) );

                        // stop the scheduler when done with job
                        sched.Shutdown( true );
                    }

                    catch ( Exception ex )
                    {
                        // create a friendly error message
                        string message = string.Format( "Error loading the job: {0}.  Ensure that the correct version of the job's assembly ({1}.dll) in the websites App_Code directory. \n\n\n\n{2}", job.Name, job.Assembly, ex.Message );
                        job.LastStatusMessage = message;
                        job.LastStatus = "Error Loading Job";
                        rockContext.SaveChanges();
                    }
                }
            }
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:53,代码来源:RunJobNowTransaction.cs

示例12: 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


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