0

以下代码产生以下错误:

Imports Quartz
Imports Quartz.Impl

Public Class InsertRssFeedJob
    Implements IJob

    Public Sub Execute(context As JobExecutionContext)
        Dim rssContoller = New RssController()
        rssController.InsertRssFeedItem("")
    End Sub

End Class

错误 1 ​​类“InsertRssFeedJob”必须为接口“Quartz.IJob”实现“Sub Execute(context As IJobExecutionContext)”。C:\Users\darchual\documents\visual studio 2010\Projects\MyBlog\MyBlog\QuartzScheduler\Class1.vb 5 16 MyBlog

我已经添加了库包引用,可以成功导入 Quartz,但是“Implements IJob”下面有一条蓝线,显示上面的错误。我能做些什么?谢谢你。

4

2 回答 2

2

这就是我使用它的方式(首先在不同的类/子中创建 scheduleFactory)......

Dim schedFact As ISchedulerFactory = New StdSchedulerFactory()

' get a scheduler
Dim sched As IScheduler = schedFact.GetScheduler()
sched.Start()

' construct job info
Dim jobDetail As New JobDetail(TriggerName, Nothing, GetType(cls_schedule))
Dim trigger As Trigger = TriggerUtils.MakeDailyTrigger(hour, min)

trigger.StartTimeUtc = DateTime.UtcNow
trigger.Name = TriggerName
sched.ScheduleJob(jobDetail, trigger)

我将类名“cls_schedule”传递给 JobDetail,然后您可以使用您的类(作为参数传递)来执行实际任务。

Public Class cls_schedule
    Implements IJob

    Public Sub Execute(ByVal context As Quartz.JobExecutionContext) Implements Quartz.IJob.Execute
        Dim jobType As String = context.Trigger.Name
                 ' Your Code Goes here
    End sub
于 2012-09-06T17:40:44.457 回答
1

它是执行方法上的签名,将其更改为 IJobContext,应该可以解决它。

于 2012-09-07T09:44:51.180 回答