/// <summary> /// Create an AzureStorage Distributed Locker. /// </summary> /// <param name="key">key for the lock.</param> /// <param name="optionsBuilder">options to build the locker.</param> /// <returns></returns> public static IDistributedLock Create(string key, Action <AzureStorageDistributedLockOptions> optionsBuilder = null) { var options = new AzureStorageDistributedLockOptions(key); optionsBuilder?.Invoke(options); var locker = new AzureStorageDistributedLock(options); return(locker); }
/// <summary> /// Create an AzureStorage Distributed Locker. /// </summary> /// <param name="key">key for the lock.</param> /// <param name="optionsBuilder">options to build the locker.</param> /// <returns></returns> public static async Task <IDistributedLock> CreateAsync(string key, Action <AzureStorageDistributedLockOptions> optionsBuilder = null) { var options = new AzureStorageDistributedLockOptions(key); optionsBuilder?.Invoke(options); var locker = new AzureStorageDistributedLock(options); await locker.Init().ConfigureAwait(false); return(locker); }
private AzureStorageDistributedLock(AzureStorageDistributedLockOptions options) { Options = options; _currentContext = new AzureStorageDistributedLockContext(this); }