gpt4 book ai didi

c# - 无法将类型 'System.Threading.tasks.task 隐式转换为

转载 作者:行者123 更新时间:2023-12-04 00:04:26 27 4
gpt4 key购买 nike

public void Start()
{

ISchedulerFactory schedFact = new StdSchedulerFactory();

IScheduler sched = schedFact.GetScheduler();
sched.Start();

IJobDetail job = JobBuilder.Create<EmailJob>()
.Build();

ITrigger trigger = TriggerBuilder.Create()
.StartNow()
.WithSimpleSchedule(x => x

.WithIntervalInHours(48)
.RepeatForever())
.Build();

sched.ScheduleJob(job, trigger);
}

我在 IScheduler sched = schedFact.GetScheduler(); 中遇到错误

上面写着

"cannot implicitly convert type System.Threading.tasks.task Quartz.Scheduler to Quartz.IScheduler"

最佳答案

schedFact.GetScheduler(); 返回 Task 您应该使用以下代码获取 IScheduler 对象:

IScheduler sched = schedFact.GetScheduler().GetAwaiter().GetResult();

关于c# - 无法将类型 'System.Threading.tasks.task<Quartz.Scheduler> 隐式转换为 <Quartz.IScheduler>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51287345/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com