Beispiel #1
0
        public static TimeoutLock Lock(object o, int timeout)
        {
            TimeoutLock tl = new TimeoutLock(o);

            if (Monitor.TryEnter(o, timeout) == false)
            {
#if DEBUG
                System.GC.SuppressFinalize(tl.leakDetector);
#endif
                Debug.Assert(false);
                throw new LockTimeoutException();
            }

            return(tl);
        }
Beispiel #2
0
    public static TimeoutLock Lock(object o, int timeout)
    {
      TimeoutLock tl = new TimeoutLock(o);

      if (Monitor.TryEnter(o, timeout) == false)
      {
#if DEBUG
        System.GC.SuppressFinalize(tl.leakDetector);
#endif
        Debug.Assert(false);
        throw new LockTimeoutException();
      }

      return tl;
    }