Spring.Net定时器使用注意
在项目开始时,需要使用定时功能,在调试模式下,没有任何问题,但是在部署到IIS后,定时器却不执行,后来才发现,由于默认的配置文件中的对象,默认是延迟实例化的。后来通过设置对象的singleton="true"。具体如下:
<objectid="JobDetail"type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject,
Spring.Scheduling.Quartz20">
<propertyname="TargetObject"ref="register"/>
<propertyname="TargetMethod"value="DeleteUploadImages"/>
</object>
<objectid="CronTrigger"type="Spring.Scheduling.Quartz.CronTriggerObject,Spring.Scheduling.Quartz20">
<propertyname="JobDetail"ref="JobDetail"/>
<!--runeverymorningat3AM-->
<!--<propertyname="CronExpressionString"value="003**?"/>-->
<propertyname="CronExpressionString"value="0/20****?"/>
</object>
<objectid="quartzSchedulerFactory"type="Spring.Scheduling.Quartz.SchedulerFactoryObject,
Spring.Scheduling.Quartz20">
<propertyname="triggers">
<list>
<refobject="CronTrigger"/>
</list>
</property>
<propertyname="AutoStartup"value="true"/>
</object>
<objectid="register"type="~/User/Register.aspx"autowire="byName"singleton="true"/>