public IAsyncLock GetOrCreate(string key, Func <Task> action) { return(GetOrCreate(key, DefaultAsyncLock.Create(options => { options.Task = action; options.ReleaseCount = 1; options.Initial = 1; options.Maximum = 1; }))); }
public IAsyncLock <T> GetOrCreate <T>(string key, Func <Task <T> > action) { var asyncLock = GetOrCreate(key, DefaultAsyncLock <T> .Create(options => { options.Task = action; options.ReleaseCount = 1; options.Initial = 1; options.Maximum = 1; })); if (asyncLock is IAsyncLock <T> genericLockAsync) { return(genericLockAsync); } asyncLock.Invoke(); return(null); }