zoukankan      html  css  js  c++  java
  • Quartz.Net 学习随手记之05 注意事项

    一、Job状态

    Quartz.NET 提供了 IStatefulJob(有状态作业)IInterruptableJob(无状作业)这2个接口;官方文档中实现方式:

    public interface IStatefulJob : IJob  { 
    }
    
    public interface IInterruptableJob : IJob  { 
      //中断方法
       void Interrupt(); 
    }

    注:一个Job实例可以被定义为"有状态的"或者"无状态的"。在执行无状态的任务过程中任何对JobDataMap所作的更改都将丢失。有状态的任务恰好相反,它在任务的每次执行之后重新存储JobDataMap。有状态任务的一个缺点就是它不能并发执行。也就是说,如果任务有状态,那么当触发器试图触发它,触发器就会被阻塞直到前面的执行完成。想使任务有状态,它就要实现 IStatefulJob 接口而不是实现IJob接口。

    二、Job并发执行

    Job类加上[DisallowConcurrentExecution]标记,可以阻止并发执行 

    三、日期说明

    The value stored in database is the DateTime.Ticks value. From MSDN:

    A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

    The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001, which represents DateTime.MinValue. It does not include the number of ticks that are attributable to leap seconds.

    public override DateTimeOffset? GetNextFireTimeUtc()
    {
        return nextFireTimeUtc;
    }
    
    public virtual object GetDbDateTimeValue(DateTimeOffset? dateTimeValue)
    {
        if (dateTimeValue != null)
        {
            return dateTimeValue.Value.UtcTicks;
        }
        return null;
    }

    转换方法

    SELECT DATEADD(HOUR, 8, DATEADD(SECOND, (NEXT_FIRE_TIME - 634241664000000000)/10000000, CONVERT(DATETIME, '2010-11-01'))) ,* FROM QRTZ_TRIGGERS
  • 相关阅读:
    WEB服务-Nginx之10-动静分离
    第10课 文件指针及目录的创建与删除
    c++ 中常用类型转换
    编译c++文件时报错:在...中已定义,例如:已经在 .obj 中定义
    No converter found for return value of type: class java.util.ArrayList
    Unable to ping server at localhost:1099
    Failed building wheel for twisted
    第六天-缺陷和缺陷报告
    第五天-黑盒测试用例设计方法(二)
    第四天-测试用例和设计方法(一)
  • 原文地址:https://www.cnblogs.com/panchunting/p/QuartzNet05_Summary.html
Copyright © 2011-2022 走看看