当我使用此代码时:
工作代码:
Public Class ImportJob
Implements IJob
Public Sub Execute(context As IJobExecutionContext) Implements IJob.Execute
'''some code
End Sub
End Class
触发代码:
Public Class ScheduleManager
Public Shared Property Scheduler As IScheduler
Public Sub RunTrigger()
Dim startTime As DateTimeOffset
startTime = DateBuilder.DateOf(20, 0, 0)
Dim scheduler = GetScheduler
Dim job As IJobDetail = JobBuilder.Create(Of ImportJob)().WithIdentity("jobname").Build()
Dim trigger As ITrigger
trigger = TriggerBuilder.Create().ForJob(job).WithIdentity("som Name").WithDescription("some Desc").StartAt(startTime).WithSimpleSchedule(Function(x) x.WithIntervalInHours(24).RepeatForever).Build()
scheduler.ScheduleJob(job, trigger)
scheduler.Start()
End Sub
Public ReadOnly Property GetScheduler As IScheduler
Get
If Scheduler Is Nothing Then
Scheduler = New StdSchedulerFactory().GetScheduler()
End If
Return Scheduler
End Get
End Property
End Class
在全球范围内:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Dim schde As New ScheduleManager
schde.RunTrigger()
End Sub
我使用此触发器和作业进行调度,当我使用该代码时,触发器必须在 20:00 触发,但触发器不触发?谢谢。