System.Threading.CancellationToken未标记为可序列化使用quartz.net 3.0时

时间:2018-01-18 07:14:19

标签: c#-4.0 serialization quartz.net

使用quartz.net 3.0新版本时,我遇到了问题:

  

System.Threading.CancellationToken未标记为可序列化

这是我的代码:

    var properties = new NameValueCollection();
    properties["quartz.scheduler.proxy"] = "true";
    properties["quartz.scheduler.proxy.address"] = "tcp://localhost:777/Scheduler";
    properties["quartz.serializer.type"] = "json";
    ISchedulerFactory schedulerFactory = new 
    StdSchedulerFactory(properties);
    var scheduler =await schedulerFactory.GetScheduler();
    await scheduler.GetJobGroupNames();

当代码运行时,我可以获取对象 scheduler ,但是当执行 GetJobGroupNames()函数时,我收到错误 System.Threading.CancellationToken Not标记为可序列化,所以我在github中查看源代码:

public virtual Task<IReadOnlyCollection<string>> GetJobGroupNames(
    CancellationToken cancellationToken = default)
{
    return CallInGuard(x => x.GetJobGroupNames(cancellationToken));
}

我不知道为什么这个功能无法工作。可以添加Serializable属性吗?但我不能。有没有人遇到过和我一样的问题?

1 个答案:

答案 0 :(得分:0)

这是3.0.0中的错误/缺陷。由于远程基础设施的遗留要求,Async / await过于急于远程接口,因此无法工作。

3.0.1将解决此问题,即从远程调用中删除Tasks和CancellationTokens。跟踪问题here