Example #1
0
 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);
 }
Example #2
0
 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);
 }