Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# quartz.net定期计划任务是否在前一个实例完成之前不运行?_C#_Scheduling_Quartz.net - Fatal编程技术网

C# quartz.net定期计划任务是否在前一个实例完成之前不运行?

C# quartz.net定期计划任务是否在前一个实例完成之前不运行?,c#,scheduling,quartz.net,C#,Scheduling,Quartz.net,我刚刚开始使用Quartz.net。我可以通过在app.config中添加以下内容来运行它 <configSections> <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e08

我刚刚开始使用Quartz.net。我可以通过在app.config中添加以下内容来运行它

<configSections>
    <section name="quartz"
     type="System.Configuration.NameValueSectionHandler, 
         System, Version=1.0.5000.0,Culture=neutral, 
         PublicKeyToken=b77a5c561934e089" />
</configSections>
正如您在作业中看到的,我有一个
线程.Sleep(TimeSpan.frommins(5))使作业睡眠五分钟。问题是,我不希望同时运行多个流程实例。在当前设置中,我仍然每隔60秒收到一条执行处理的
消息


是否有一种方法可以使用Quartz.net使此作业仅在其上一个实例完成后运行?

在这里,您应该使用[DisallowConcurrentExecution]属性标记作业。此处解释了其背后的原因/行为(IStatefulJob marker interface是2.0之前的做法)。

这是您应该使用[DisallowConcurrentExecution]属性标记作业的地方。这里解释了这背后的原因/行为(IStatefulJob marker接口是2.0之前的发展方向)

<!-- Configure Thread Pool -->
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />

<!-- Check for updates to the scheduling every 10 seconds -->
<add key="quartz.plugin.xml.scanInterval" value="10" />

<!-- Configure Job Store -->
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
<add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz"/>
<add key="quartz.plugin.xml.fileNames" value="quartz.config" />
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                version="2.0">
  <processing-directives>
    <overwrite-existing-data>true</overwrite-existing-data>
  </processing-directives>

  <schedule>
    <job>
      <name>ResultProcessor</name>
      <group>Result</group>
      <description>Normalizes results.</description>
      <job-type>TestingNamespace.TestingJob,xxx</job-type>
    </job>

    <trigger>
      <simple>
        <name>ResultProcessorTrigger</name>
        <group>Result</group>
        <description>Trigger for result processor</description>
        <job-name>ResultProcessor</job-name>
        <job-group>Result</job-group>
        <misfire-instruction>SmartPolicy</misfire-instruction>
        <repeat-count>-1</repeat-count>
        <repeat-interval>60000</repeat-interval> <!-- Every 60 seconds -->
      </simple>
    </trigger>
  </schedule>
</job-scheduling-data>
namespace TestingNamespace
{
    class TestingJob: IJob
    {
        protected static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public void Execute(IJobExecutionContext context)
        {
            try
            {
                logger.Info("Executing PROCESSING");
                Thread.Sleep(TimeSpan.FromMinutes(5));
            }
            catch (Exception ex)
            {
                logger.Error("Problem running Execute.", ex);
                throw;
            } // End of catch
        } // End of Run
    } // End of TestingJob
} // End of namespace