Example #1
0
		public static TimedLock Lock(object obj, TimeSpan timeout)
		{
			TimedLock timedLock = new TimedLock(obj);
			if (!Monitor.TryEnter(obj, timeout))
			{
				#if DEBUG
				GC.SuppressFinalize(timedLock._leakDetector);
				#endif
				throw Error.OperationTimeout(timeout);
			}
			return timedLock;
		}
Example #2
0
        public static TimedLock Lock(object obj, TimeSpan timeout)
        {
            TimedLock timedLock = new TimedLock(obj);

            if (!Monitor.TryEnter(obj, timeout))
            {
                                #if DEBUG
                GC.SuppressFinalize(timedLock._leakDetector);
                                #endif
                throw Error.OperationTimeout(timeout);
            }
            return(timedLock);
        }