예제 #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;
		}
예제 #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);
        }