ECM
ECM
总版主
总版主
  • 社区居民
  • 忠实会员
  • 原创写手
阅读:807回复:0

How to implement Quartz.net Scheduler for simple HelloWorld

楼主#
更多 发布于:2016-05-16 10:53
The following code produces the following error: 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
 Error 1 Class 'InsertRssFeedJob' must implement 'Sub Execute(context As IJobExecutionContext)' for interface 'Quartz.IJob'. C:\Users\darchual\documents\visual studio 2010\Projects\MyBlog\MyBlog\QuartzScheduler\Class1.vb 5 16 MyBlog I have added the library package reference and can import Quartz successfully, but "Implements IJob" has a blue line underneath of it and displays the error above. What can I do? Thank you.
answer(解决方案):

This is How I use it (first create scheduleFactory, in a different class/Sub)... 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)
 I passed the class name "cls_schedule" to JobDetail, Then you can use your class (which was passed as parameter) to Excute the actuall task. 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

 

 

 

 

 

 

 

异常中心网是一家专门收集整理程序员编程过程中遇到的常见异常(exception)以及各种异常问答中心的网站。异常中心网旨在,减少程序员在编码遇到异常,处理各种异常时间和痛苦,让程序员能更愉快的、快速的定位异常并查找对应的异常解决方案。异常中心网诚心打造最完美的编程社区为程序员用户服务,努力成为最好的程序员乐园程序员社区程序异常中心程序bug中心异常问答中心

 

喜欢0 评分0
游客

返回顶部