コード例 #1
0
 /// <summary>
 /// Tries to acquire a lock with the specified parameters
 /// </summary>
 /// <param name="name">Unique name of the lock</param>
 /// <param name="timeout">Time span to wait for the lock before timing out</param>
 /// <param name="distributedLock">The ILockFile instance on success or null if the lock couldn't be acquired.</param>
 /// <returns>True if the lock could be acquired and false if not.</returns>
 public static bool TryAcquireLock(this IDistributedLockManager lockFileManager, string name, TimeSpan timeout, out IDistributedLock distributedLock)
 {
     distributedLock = lockFileManager.TryAcquireLock(name, timeout);
     return(distributedLock != null);
 }
コード例 #2
0
 /// <summary>
 /// Tries to acquire a lock with the specified parameters
 /// </summary>
 /// <param name="name">Unique name of the lock</param>
 /// <returns>The ILockFile instance on success or null if the lock couldn't be acquired.</returns>
 public static IDistributedLock TryAcquireLock(this IDistributedLockManager lockFileManager, string name)
 {
     return(lockFileManager.TryAcquireLock(name, new TimeSpan(0, 0, 0, 4)));
 }