Spring.Net定时器使用注意

在项目开始时,需要使用定时功能,在调试模式下,没有任何问题,但是在部署到IIS后,定时器却不执行,后来才发现,由于默认的配置文件中的对象,默认是延迟实例化的。后来通过设置对象的singleton="true" 。具体如下:
<object id="JobDetail" type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject,
Spring.Scheduling.Quartz20">
    <property name="TargetObject" ref="register" />
    <property name="TargetMethod" value="DeleteUploadImages" />
  </object>

  <object id="CronTrigger" type="Spring.Scheduling.Quartz.CronTriggerObject, Spring.Scheduling.Quartz20">
    <property name="JobDetail" ref="JobDetail"/>
    <!--run every morning at 3 AM -->
    <!--<property name="CronExpressionString" value="0 0 3 * * ?" />-->
    <property name="CronExpressionString" value="0/20 * * * * ?"/>
  </object>

  <object id="quartzSchedulerFactory" type="Spring.Scheduling.Quartz.SchedulerFactoryObject,
Spring.Scheduling.Quartz20">
    <property name="triggers">
      <list>
        <ref object="CronTrigger" />
      </list>
    </property>
    <property name="AutoStartup" value="true"/>
  </object>
  <object id="register" type="~/User/Register.aspx" autowire="byName" singleton="true" />

你可能感兴趣的:(spring)