Sub Main()
Dim oSchedule As Action(Of SimpleScheduleBuilder)
Dim oTrigger As Func(Of ITrigger)
Dim oDetail As Func(Of IJobDetail)
Dim oJob As Action(Of QuartzConfigurator)
oSchedule = Function(ScheduleBuilder) As SimpleScheduleBuilder
Return ScheduleBuilder.WithIntervalInSeconds(5).RepeatForever
End Function
oTrigger = Function() As ITrigger
Return TriggerBuilder.Create.WithIdentity(QbBackup.Job.Trigger, QbBackup.Job.Group).WithSimpleSchedule(oSchedule).Build
End Function
oDetail = Function()
Return JobBuilder.Create(Of QbBackup.Job).WithIdentity(QbBackup.Job.Name, QbBackup.Job.Group).Build
End Function
oJob = Function(Configurator As QuartzConfigurator)
Return Configurator.WithJob(oDetail).AddTrigger(oTrigger)
End Function
HostFactory.Run(Sub(Configurator)
Configurator.Service(Of Manager)(Sub(Service)
Service.ConstructUsing(Function(Factory) As ServiceControl
Return New Manager
End Function)
Service.WhenStarted(Function(Notifier, HostControl) As Boolean
Return Notifier.StartService(HostControl)
End Function)
Service.WhenStopped(Function(Notifier, HostControl) As Boolean
Return Notifier.StopService(HostControl)
End Function)
Service.ScheduleQuartzJob(oJob)
End Sub)
Configurator.SetDescription(SchedulerInfo.Description)
Configurator.SetServiceName(SchedulerInfo.Product)
Configurator.SetDisplayName(SchedulerInfo.Title)
Configurator.StartAutomatically()
Configurator.RunAsLocalSystem()
End Sub)
End Sub
Imports Common.Logging
Public Class Job
Implements IJob
Private Shared Logger As ILog = LogManager.GetLogger(GetType(Job))
Public Sub Execute(Context As IJobExecutionContext) Implements IJob.Execute
Try
Job.Logger.Info(Now.ToString)
Catch ex As Exception
Throw New JobExecutionException(ex.Message, ex)
End Try
End Sub
Public Shared ReadOnly Property Name As String
Get
Return QbBackupInfo.Product
End Get
End Property
Public Shared ReadOnly Property Trigger As String
Get
Return "{0}Trigger".ToFormat(Job.Name)
End Get
End Property
Public Shared ReadOnly Property Group As String
Get
Return "{0}Group".ToFormat(Job.Name)
End Get
End Property
End Class
--
You received this message because you are subscribed to the Google Groups "Quartz.NET" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quartznet+...@googlegroups.com.
To post to this group, send email to quar...@googlegroups.com.
Visit this group at http://groups.google.com/group/quartznet.
For more options, visit https://groups.google.com/d/optout.
Dim oProperties As NameValueCollection
Dim oScheduler As IScheduler
Dim oFactory As ISchedulerFactory
oProperties = New NameValueCollection
'Build up properties here
'...
'...
'...
oFactory = New StdSchedulerFactory(oProperties)
oScheduler = oFactory.GetScheduler()
oScheduler.Start()