public override bool TryLock(TimeSpan timespan) { Thread caller = Thread.CurrentThread; lock (this) { if (_owner == null) { _owner = caller; _holds = 1; return true; } else if (caller == _owner) { ++_holds; return true; } } WaitNode n = new WaitNode(); return n.DoTimedWait(this, timespan); }
public override bool TryLock(TimeSpan timespan) { Thread caller = Thread.CurrentThread; lock (this) { if (GetHold(caller)) return true; } WaitNode n = new WaitNode(); return n.DoTimedWait(this, timespan); }