Example #1
0
        public static TimedLock Lock(object o, TimeSpan timeout)
        {
            var tl = new TimedLock(o);
              if (!Monitor.TryEnter(o, timeout))
              {
            #if DEBUG
            GC.SuppressFinalize(tl.leakDetector);
            #endif
            throw new LockTimeoutException();
              }

              return tl;
        }
Example #2
0
        public static TimedLock Lock(object o, TimeSpan timeout)
        {
            var tl = new TimedLock(o);

            if (!Monitor.TryEnter(o, timeout))
            {
#if DEBUG
                GC.SuppressFinalize(tl.leakDetector);
#endif
                throw new LockTimeoutException();
            }

            return(tl);
        }