c# - Hangfire 禁用并发执行 : What happens when the timeout expires?

标签 c# hangfire

根据 Hangfire 0.8.2 announcement post , Hangfire 有一个 DisableConcurrentExecution 过滤器,当应用于一个方法时,它会阻止该方法的多个实例同时执行。

DisableConcurrentExecution 过滤器采用 timeoutInSeconds int 参数。来自链接文章中的示例:

[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)]
public void SomeMethod()
{
    // Operations performed inside a distributed lock
}

我的问题是:给定一个正在等待为 DisableConcurrentExecution 过滤方法获取锁的作业,当该作业等待的时间超过 timeoutInSeconds< 时会发生什么值?

最佳答案

我最近对此进行了测试。该作业实例在仪表板中被记录为失败,并列出了表明在等待独占锁时超时已过期的异常。

您会看到以下异常:

Hangfire.Storage.DistributedLockTimeoutException: Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'xxx' resource.
    at Hangfire.SqlServer.SqlServerDistributedLock.Acquire(IDbConnection connection, String resource, TimeSpan timeout)

关于c# - Hangfire 禁用并发执行 : What happens when the timeout expires?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40515961/

相关文章:

c# - 如何在松散耦合的应用程序中将状态信息传递给 GUI

distributed-transactions - Hangfire:Azure SQL:添加新作业失败

c# - 在 ASP.net Core 上使用 hangfire 和 structuremap 有什么更好的方法吗?

c# - Hangfire 单实例重复作业

jwt - 同一站点中的 asp net core 2.0 JWT 和 Openid Connect 身份验证

c# - 我从 C# 成功调用了 advapi32 的 LsaEnumerateAccountRights()。现在如何解码它返回的 LSA_UNICODE_STRING 数组?

c# - 生成随 secret 码

c# - 如何获取单选按钮的值?

c# - 如何知道从 C++ dll 传递到 C# 的数组的大小

c# - 在 HangFire 中设置一个只有 "on demand"的作业