コード例 #1
0
ファイル: MonitorVault.cs プロジェクト: lanicon/DotNetVault
 private MonitorLockedResource ExecuteGetInternalLockedResourceDuringDispose(TimeSpan timeOut)
 {
     ThrowIfNotDisposing();
     if (timeOut <= TimeSpan.Zero)
     {
         throw new ArgumentOutOfRangeException(nameof(timeOut), timeOut, @"Must be positive.");
     }
     return(MonitorLockedResource.CreateInternalLockedResource(this, timeOut, CancellationToken.None, true));
 }
コード例 #2
0
ファイル: MonitorVault.cs プロジェクト: lanicon/DotNetVault
 /// <summary>
 /// Try to get the resource until earliest of following happens
 ///     1- get it successfully,
 ///     2- cancellation requested via <paramref name="token"/>
 ///     3- time specified by <paramref name="timeout"/> exceeded
 /// </summary>
 /// <param name="timeout">how long should we wait?  Null indicates potential infinite wait .</param>
 /// <param name="token">token by which another thread can cancel the attempt to obtain resource</param>
 /// <returns>the resource</returns>
 /// <exception cref="ArgumentOutOfRangeException">non-null, non-positive <paramref name="timeout"/> argument</exception>
 /// <exception cref="TimeoutException">didn't obtain it within time specified by <paramref name="timeout"/></exception>
 /// <exception cref="OperationCanceledException">operation was cancelled</exception>
 /// <exception cref="ObjectDisposedException">the object was disposed</exception>
 /// <exception cref="LockAlreadyHeldThreadException">the thread attempting to obtain the lock already holds the lock.</exception>
 /// <remarks>After method returns value, you are responsible for disposal until passing to ultimate user behind a method whose return
 /// value is annotated by the <see cref="UsingMandatoryAttribute"/>.  This means you must dispose of it yourself in all failure/exceptional
 /// cases after this method returns a value but before ultimately passed to user.</remarks>
 protected MonitorLockedResource ExecuteGetInternalLockedResource(TimeSpan?timeout, CancellationToken token)
 {
     ThrowIfDisposingOrDisposed();
     if (timeout.HasValue && timeout.Value <= TimeSpan.Zero)
     {
         throw new ArgumentOutOfRangeException(nameof(timeout), timeout, @"Must be positive.");
     }
     return(MonitorLockedResource.CreateInternalLockedResource(this, timeout, token));
 }
コード例 #3
0
ファイル: MonitorVault.cs プロジェクト: lanicon/DotNetVault
 /// <summary>
 /// Try to get the locked resource.  This thread will block (potentially forever)
 /// until the resource is obtained or an exception is thrown.
 /// </summary>
 /// <returns>The locked resource</returns>
 /// <exception cref="ObjectDisposedException">object was disposed</exception>
 /// <exception cref="LockAlreadyHeldThreadException">the thread attempting to obtain the lock,
 /// already holds the lock.</exception>
 protected MonitorLockedResource ExecuteGetInternalLockedResourceBlockForever()
 {
     ThrowIfDisposingOrDisposed();
     return(MonitorLockedResource.CreateInternalLockedResourceBlockForever(this));
 }