C# 可中断作业的测试

C# 可中断作业的测试,c#,quartz.net,C#,Quartz.net,我有以下代码: private static void InterruptAJob(JobKey foundJobKey, IScheduler sched) { if (null != foundJobKey) { sched.Interrupt(foundJobKey); } } 我得到了这个例外(我希望是这样): 无法中断作业“groupName001.testJobDetailImpl_0”

我有以下代码:

    private static void InterruptAJob(JobKey foundJobKey, IScheduler sched)
    {
        if (null != foundJobKey)
        {
            sched.Interrupt(foundJobKey);
        }
    }
我得到了这个例外(我希望是这样):

无法中断作业“groupName001.testJobDetailImpl_0”,因为它未实现Quartz.IIInterruptableJob

有没有一种方法可以使用“JobKey”测试IIInterruptableJob

编辑(追加)

//
///在此调度程序实例中请求所有
///当前正在执行已标识的实例,其中
///必须是接口的实现者。
/// 
/// 
/// 
///如果标识作业的多个实例当前正在执行,
///将在上调用该方法
///每一个实例。然而,有一个限制,在这种情况下
///在一个实例上抛出一个异常,所有
///其余实例(尚未中断)将不会被中断
///他们的方法叫做。
/// 
/// 
///如果您希望中断作业的特定实例(超过
///一个正在执行)您可以通过调用
///掌握
///到作业实例,然后对其调用
///你自己。
/// 
/// 
///此方法不支持群集。也就是说,它只会中断
///当前在此数据库中执行的已标识可中断作业的实例
///调度程序实例,而不是整个集群。
/// 
/// 
///true表示至少找到并中断了所标识作业的一个实例。
///如果作业未执行,则无法中断JobException
/// 
/// 
公共虚拟bool中断(JobKey JobKey)
{
注释说使用isScheduler.GetCurrentlyExecutingJobs()。 这给了我一个JobKey的集合

我想问这个问题的另一种方式是…我如何获得下面的功能


IsScheduler.GetCurrentlyExecutionGiInterruptableJobs

为什么不让参数的类型为
IIInterruptableJob
,这样您就知道它会一直工作?我认为单用键是不可能的,但您可以加载作业,并查看它是否使用
is
操作符实现IIInterruptableJob接口@布莱恩。是的,这是我的主意……但我想在编写额外的代码之前确认一下。@Servy。那么如何才能得到使用API的唯一IInteruptableJob的列表呢?
/// <summary>
/// Request the interruption, within this Scheduler instance, of all
/// currently executing instances of the identified <see cref="IJob" />, which
/// must be an implementor of the <see cref="IInterruptableJob"/> interface.
/// </summary>
/// <remarks>
/// <para>
/// If more than one instance of the identified job is currently executing,
/// the <see cref="IInterruptableJob.Interrupt"/> method will be called on
/// each instance. However, there is a limitation that in the case that
/// <see cref="Interrupt(JobKey)"/> on one instances throws an exception, all
/// remaining instances (that have not yet been interrupted) will not have
/// their <see cref="Interrupt(JobKey)"/> method called.
/// </para>
/// <para>
/// If you wish to interrupt a specific instance of a job (when more than
/// one is executing) you can do so by calling
/// <see cref="GetCurrentlyExecutingJobs"/> to obtain a handle
/// to the job instance, and then invoke <see cref="Interrupt(JobKey)"/> on it
/// yourself.
/// </para>
/// <para>
/// This method is not cluster aware. That is, it will only interrupt
/// instances of the identified InterruptableJob currently executing in this
/// Scheduler instance, not across the entire cluster.
/// </para>
/// </remarks>
/// <returns>true is at least one instance of the identified job was found and interrupted.</returns>
/// <throws> UnableToInterruptJobException if the job does not implement </throws>
/// <seealso cref="IInterruptableJob"/>
/// <seealso cref="GetCurrentlyExecutingJobs"/>
public virtual bool Interrupt(JobKey jobKey)
{