예제 #1
0
        /// <summary>Locks the specified object and returns an IDisposable that can be used to release the lock.</summary>
        /// <param name="monitor">The object on which to acquire the monitor lock.</param>
        /// <returns>An IDisposable that can be used to release the lock.</returns>
        public static IDisposable Lock(object monitor)
        {
            if (monitor == null)
            {
                throw new ArgumentNullException("monitor");
            }

            IDisposable cookie = new DeadlockMonitorCookie(monitor);

            Enter(monitor);

            return(cookie);
        }
예제 #2
0
        /// <summary>Locks the specified object and returns an IDisposable that can be used to release the lock.</summary>
        /// <param name="monitor">The object on which to acquire the monitor lock.</param>
        /// <returns>An IDisposable that can be used to release the lock.</returns>
        public static IDisposable Lock(object monitor)
        {
            if (monitor == null) throw new ArgumentNullException("monitor");

            IDisposable cookie = new DeadlockMonitorCookie(monitor);
            Enter(monitor);

            return cookie;
        }