Source/NFX/KeyedMonitor.cs
/// <summary>
/// Tries to perform Monitor.TryEnter() on TKey value.
/// Returns true when lock was taken. Unlike Enter() this method does not block
/// </summary>
Tries to perform Monitor.TryEnter() on TKey value.
Returns true when lock was taken. Unlike Enter() this method does not block
Tries to perform Monitor . TryEnter () on TKey value . Returns true when lock was taken . Unlike Enter () this method does not block
public bool TryEnter(TKey key)
    {
      var bucket = getBucket(key);
      _slot _lock;
      lock (bucket)
      {
        if (!bucket.TryGetValue(key, out _lock))
        {
          _lock = new _slot();
          Monitor.Enter(_lock);
          bucket.Add(key, _lock);
          return true;
        }
      }
      return false;
    }
public bool TryEnter ( TKey key ) { var bucket = getBucket ( key ) ; _slot _lock ; lock ( bucket ) { if ( ! bucket . TryGetValue ( key , out _lock ) ) { _lock = new _slot ( ) ; Monitor . Enter ( _lock ) ; bucket . Add ( key , _lock ) ; return true ; } } return false ; }
Tries to perform Monitor.TryEnter() on TKey value.
Tries to perform Monitor . TryEnter () on TKey value .
key
TKey