public ExcludeLock(NmsSynchronizationMonitor parent) { this.parent = parent; currentLock = parent.GetCurrentLock(); parent.SetCurrentLock(null); }
TryLockAsync( int timeout) // 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(TryEnterAsync(timeout, nmsLock)); }
public NmsLock Lock() { NmsLock nmsLock = GetOrCreateCurrentLock(); nmsLock.Enter(); return(nmsLock); }
public IDisposable Lock() { NmsLock nmsLock = GetOrCreateCurrentLock(); nmsLock.Enter(); return(nmsLock); }
private async Task <NmsLock> TryEnterAsync(int timeout, NmsLock nmsLock) { try { nmsLock = await nmsLock.EnterAsync(timeout).Await(); return(nmsLock); } catch (Exception) { return(null); } }
private void SetCurrentLock(NmsLock nmsLock) { asyncLocal.Value = nmsLock; }