Esempio n. 1
0
 /// <summary>
 /// Attempts to aquire a lock to access the section of code (non-blocking).
 /// (Note: You must check the returned LockToken in this case to ensure that
 /// the lock was actually aquired.)
 /// </summary>
 /// <returns>LockToken object</returns>
 public bool TryAquireLock(out LockToken lockToken)
 {
     if (_mutex.WaitForMutex(1))
     {
         lockToken = new LockToken(this);
         return(true);
     }
     lockToken = default(LockToken);
     return(false);
 }
Esempio n. 2
0
 /// <summary>
 /// Attempts to aquire a lock to access the section of code (non-blocking).
 /// (Note: You must check the returned LockToken in this case to ensure that
 /// the lock was actually aquired.)
 /// </summary>
 /// <returns>LockToken object</returns>
 public bool TryAquireLock(out LockToken lockToken)
 {
     if (_criticalSection.TryEnter())
     {
         lockToken = new LockToken(this);
         return(true);
     }
     lockToken = default(LockToken);
     return(false);
 }
Esempio n. 3
0
 /// <summary>
 /// Attempts to aquire a lock to access the section of code (non-blocking).
 /// (Note: You must check the returned LockToken in this case to ensure that
 /// the lock was actually aquired.)
 /// </summary>
 /// <returns>LockToken object</returns>
 public bool TryAquireLock(out LockToken lockToken)
 {
     if (CMonitor.TryEnter(_monitorObject))
     {
         lockToken = new LockToken(this);
         return(true);
     }
     lockToken = default(LockToken);
     return(false);
 }