我希望能够像这样编写代码:
using (await LockAsync(x.Id))
{
// here goes code that is unsafe with respect to x.Id
// because it can be executed in multiple threads on
// the same instance or on multiple instances (e.g.
// multiple Azure Functions
}
我知道有一些开箱即用的方法可以锁定整个执行上下文,而不需要使用密钥(例如函数中的[ActivityTrigger]
),我也知道我可以使用blob租赁来自己创建密钥锁,但是是否有一种开箱即用的方法可以进行密钥锁定呢?