How to create quartz job that will runs every N seconds even if job takes more time

戏子无情 提交于 2019-12-04 18:06:54

What if you let your job run concurrently, but amend it to do nothing if the job is already running, eg something like.

public class StatefulJob : IJob 
{
    private static bool Running;

    public void Execute(IJobExecutionContext context)
    {                       
        if (Running)
            return;

        Running = true;                                     
        try
        {
            Console.WriteLine(" StateFull START " + DateTime.Now.ToString());
            Thread.Sleep(7000);
            Console.WriteLine(" StateFull END " + DateTime.Now.ToString());
        }
        finally
        {
            Running = false;
        }

    }            
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!