using System;
using Quartz;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hatirlaticiapp
{
public class Notification : IJob
{
public void Execute(IJobExecutionContext context)
{
JobDataMap data = context.JobDetail.JobDataMap;
Task task = (Task)data["Task"];
task.OnNotificationStarted(task, EventArgs.Empty);
}
}
}
对于这行代码,我得到了这样的警告。
错误:
错误通知‘CS0738’不实现接口成员'IJob.Execute(IJobExecutionContext)‘。“Notification.Execute(IJobExecutionContext)”“无法实现”“IJob.Execute(IJobExecutionContext)”“,因为它没有匹配的返回类型”“Task”“。”
编辑1:添加我的调度代码
public class NotificationController : IController<Task>
{
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
IScheduler scheduler;
public NotificationController()
{
scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
}
}
我在这里也得到了这个错误
错误:无法将类型'System.Threading.Tasks.Task‘隐式转换为“Quartz.IScheduler”。存在显式转换(是否缺少强制转换?)
请帮帮我。
发布于 2018-06-05 00:36:43
查看https://www.quartz-scheduler.net/documentation/quartz-3.x/tutorial/index.html可能会有所帮助,因为它看起来您的一些代码是为版本2.2编写的,但错误消息会提示您正在使用版本3。
特别是你的第二个错误可能是因为你错过了等待,即
scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
应该是
scheduler = await schedulerFactory.GetScheduler();
await scheduler.Start();
另外,你的第一个签名应该是
public async Task Execute(IJobExecutionContext context)
并且假设您需要在实际代码中使用await
。
发布于 2018-06-03 01:21:14
阅读整个异常,末尾写着
... because it does not have the matching return type of 'Task'.
将返回值从void
改为Task
。
https://stackoverflow.com/questions/50658932
复制相似问题