本文整理汇总了C#中Quartz.Impl.StdSchedulerFactory.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# StdSchedulerFactory.Initialize方法的具体用法?C# StdSchedulerFactory.Initialize怎么用?C# StdSchedulerFactory.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quartz.Impl.StdSchedulerFactory
的用法示例。
在下文中一共展示了StdSchedulerFactory.Initialize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethod1
public void TestMethod1()
{
var quartzBuilder = new StdSchedulerFactory();
quartzBuilder.Initialize();
var bus = ServiceBusFactory.New(sbi =>
{
sbi.UseMsmq();
sbi.UseMulticastSubscriptionClient();
sbi.ReceiveFrom("msmq://localhost/clustertest-1");
sbi.UseClusterService(cc =>
{
cc.SetEndpointIndex(1);
cc.SetElectionPeriod(TimeSpan.FromSeconds(5));
cc.UseScheduler(quartzBuilder.GetScheduler);
});
sbi.EnableMessageTracing();
sbi.UseNLog(_logFactory);
});
var evt = new ManualResetEventSlim(false);
bus.SubscribeHandler<TimeoutExpired>(m =>
{
evt.Set();
});
Thread.Sleep(5000);
bus.Publish(new ScheduleTimeout(Guid.Empty, TimeSpan.FromSeconds(10)));
Assert.IsTrue(evt.Wait(TimeSpan.FromSeconds(30)), "Didn't get a timeout expired message");
}
示例2: Init
public void Init()
{
Configure.Instance.Configurer.ConfigureComponent<IScheduler>(() =>
{
var factory = new StdSchedulerFactory();
factory.Initialize();
var scheduler = factory.GetScheduler();
return scheduler;
}, DependencyLifecycle.SingleInstance);
}
示例3: TestFactoryShouldOverrideConfigurationWithSysProperties
public void TestFactoryShouldOverrideConfigurationWithSysProperties()
{
NameValueCollection properties = new NameValueCollection();
var factory = new StdSchedulerFactory();
factory.Initialize();
var scheduler = factory.GetScheduler();
Assert.AreEqual("DefaultQuartzScheduler", scheduler.SchedulerName);
Environment.SetEnvironmentVariable("quartz.scheduler.instanceName", "fromSystemProperties");
factory = new StdSchedulerFactory();
scheduler = factory.GetScheduler();
Assert.AreEqual("fromSystemProperties", scheduler.SchedulerName);
}
示例4: Init
public void Init()
{
var configurer = Configure.Instance.Configurer;
configurer.ConfigureComponent<IJobFactory>(() => new QuartzJobFactory(Configure.Instance.Builder),DependencyLifecycle.InstancePerUnitOfWork);
configurer.ConfigureComponent<IScheduler>(() =>
{
var factoryx = new StdSchedulerFactory();
factoryx.Initialize();
var scheduler = factoryx.GetScheduler();
scheduler.JobFactory = Configure.Instance.Builder.Build<IJobFactory>();
return scheduler;
}, DependencyLifecycle.SingleInstance);
configurer.ConfigureComponent<DoSomethingJob>(DependencyLifecycle.InstancePerUnitOfWork);
}
示例5: QuartzRegistry
public QuartzRegistry(IContainer container)
{
For<IJobFactory>().Use(() => new QuartzJobFactory(container));
For<IScheduler>().Singleton().Use(() =>
{
var stdSchedulerFactory = new StdSchedulerFactory();
stdSchedulerFactory.Initialize();
var scheduler = stdSchedulerFactory.GetScheduler();
scheduler.JobFactory = container.GetInstance<IJobFactory>();
return scheduler;
});
}
示例6: TestFactoryShouldOverrideConfigurationWithSysProperties
public async Task TestFactoryShouldOverrideConfigurationWithSysProperties()
{
NameValueCollection properties = new NameValueCollection();
properties["quartz.serializer.type"] = TestConstants.DefaultSerializerType;
var factory = new StdSchedulerFactory(properties);
factory.Initialize();
var scheduler = await factory.GetScheduler();
Assert.AreEqual("QuartzScheduler", scheduler.SchedulerName);
Environment.SetEnvironmentVariable("quartz.scheduler.instanceName", "fromSystemProperties");
// Make sure to pass the serializer type as an env var instead of in a NameValueCollection (as in the previous test)
// since passing an explicit NameValueCollection causes the scheduler factory to not check environment variables
Environment.SetEnvironmentVariable("quartz.serializer.type", TestConstants.DefaultSerializerType);
factory = new StdSchedulerFactory();
scheduler = await factory.GetScheduler();
Assert.AreEqual("fromSystemProperties", scheduler.SchedulerName);
}
示例7: GetSchedulerFactory
/// <summary>
/// Gets the scheduler factory.
/// </summary>
/// <returns>The ISchedulerFactory.</returns>
private static ISchedulerFactory GetSchedulerFactory()
{
var result = new StdSchedulerFactory();
var props = ConfigurationManager.GetSection(QuartzConfigurationSectionName);
if (props != null)
{
// Initialize factory with settings from config file.
result.Initialize();
}
else
{
result.Initialize(GetDefaultProperties());
}
return result;
}