public static void TryEnter(object obj, ref bool lockTaken) { if (lockTaken) { Monitor.ThrowLockTakenException(); } Monitor.ReliableEnterTimeout(obj, 0, ref lockTaken); }
public static void TryEnter(object obj, TimeSpan timeout, ref bool lockTaken) { if (lockTaken) { Monitor.ThrowLockTakenException(); } Monitor.ReliableEnterTimeout(obj, Monitor.MillisecondsTimeoutFromTimeSpan(timeout), ref lockTaken); }