/// <summary> /// Creates an in memory job store (<see cref="RAMJobStore" />) /// The thread priority is set to Thread.NORM_PRIORITY /// </summary> /// <param name="maxThreads">The number of threads in the thread pool</param> public virtual void CreateVolatileScheduler(int maxThreads) { SimpleThreadPool threadPool = new SimpleThreadPool(maxThreads, ThreadPriority.Normal); threadPool.Initialize(); IJobStore jobStore = new RAMJobStore(); CreateScheduler(threadPool, jobStore); }
public void Start() { var configFileNames = string.Join(",", Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, ConfigName)); if (string.IsNullOrWhiteSpace(configFileNames)) { return; } var instanceId = new SimpleInstanceIdGenerator().GenerateInstanceId(); var threadPool = new SimpleThreadPool(threadCount: 2, threadPriority: ThreadPriority.Normal) { InstanceName = SchedulerName }; threadPool.Initialize(); var jobStore = new RAMJobStore { InstanceName = SchedulerName, InstanceId = instanceId, }; var jobInitializationPlugin = new ConfigFileProcessorPlugin { FileNames = configFileNames, ScanInterval = QuartzConfigFileScanInterval.DisableScanning }; DirectSchedulerFactory.Instance.CreateScheduler( SchedulerName, instanceId, threadPool, jobStore, new Dictionary <string, ISchedulerPlugin> { { SchedulerName, jobInitializationPlugin } }, TimeSpan.Zero, TimeSpan.Zero); var scheduler = DirectSchedulerFactory.Instance.GetScheduler(SchedulerName); scheduler.JobFactory = _jobFactory; scheduler.Start(); }
public void Start() { var instanceId = new SimpleInstanceIdGenerator().GenerateInstanceId(); var threadPool = new SimpleThreadPool(threadCount: 2, threadPriority: ThreadPriority.Normal) { InstanceName = SchedulerName }; threadPool.Initialize(); var jobstore = new RAMJobStore { InstanceName = SchedulerName, InstanceId = instanceId, }; var baseUri = new Uri(Assembly.GetExecutingAssembly().GetName().EscapedCodeBase); // ReSharper disable once AssignNullToNotNullAttribute var fileName = Path.Combine(Path.GetDirectoryName(baseUri.LocalPath), ConfigName); var jobInitializationPlugin = new ConfigFileProcessorPlugin { FileNames = fileName, ScanInterval = QuartzConfigFileScanInterval.DisableScanning }; DirectSchedulerFactory.Instance.CreateScheduler( SchedulerName, instanceId, threadPool, jobstore, new Dictionary <string, ISchedulerPlugin> { { SchedulerName, jobInitializationPlugin } }, TimeSpan.Zero, TimeSpan.Zero); var scheduler = DirectSchedulerFactory.Instance.GetScheduler(SchedulerName); scheduler.JobFactory = _jobFactory; scheduler.Start(); }
public void TestPlugins() { StringBuilder result = new StringBuilder(); IDictionary <string, ISchedulerPlugin> data = new Dictionary <string, ISchedulerPlugin>(); data["TestPlugin"] = new TestPlugin(result); IThreadPool threadPool = new SimpleThreadPool(1, ThreadPriority.Normal); threadPool.Initialize(); DirectSchedulerFactory.Instance.CreateScheduler( "MyScheduler", "Instance1", threadPool, new RAMJobStore(), data, TimeSpan.Zero, TimeSpan.Zero); IScheduler scheduler = DirectSchedulerFactory.Instance.GetScheduler("MyScheduler"); scheduler.Start(); scheduler.Shutdown(); Assert.AreEqual("TestPlugin|MyScheduler|Start|Shutdown", result.ToString()); }