How can I set the number of threads in the Quartz.NET threadpool?

前端 未结 3 1112
谎友^
谎友^ 2020-12-16 03:28

I\'ve seen in this tutorial section of the Quartz.NET documentation that it should be possible to define the maximum number of threads the Quartz scheduler is going to use.

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 03:56

    You can do this programmatically with the code below if you don't want to rely on the external quartz.config file for whatever reason:

        var properties = new NameValueCollection { {"quartz.threadPool.threadCount", "1"} };
    
        var schedulerFactory = new StdSchedulerFactory(properties);
        var scheduler = schedulerFactory.GetScheduler();
    

    I agree with the comments in the accepted answer though that in this case you probably want to use [DisallowConcurrentExecutionAttribute] on your IJob class instead.

提交回复
热议问题