/// <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); }
/// <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; }