private async Task <NmsLock> TryEnterAsync(int timeout, NmsLock nmsLock) { try { nmsLock = await nmsLock.EnterAsync(timeout).Await(); return(nmsLock); } catch (Exception) { return(null); } }
LockAsync() // This should not be async method, cause setting asyncLocal inside GetOrCreateCurrentLock may be only limited to this method in such case { NmsLock nmsLock = GetOrCreateCurrentLock(); return(nmsLock.EnterAsync()); }