Esempio n. 1
0
 private AtomicLockedResource ExecuteGetInternalLockedResourceDuringDispose(TimeSpan timeOut, bool spin)
 {
     ThrowIfNotDisposing();
     if (timeOut <= TimeSpan.Zero)
     {
         throw new ArgumentOutOfRangeException(nameof(timeOut), timeOut, @"Must be positive.");
     }
     return(AtomicLockedResource.CreateInternalLockedResource(this, timeOut, spin, true));
 }
Esempio n. 2
0
        private AtomicLockedResource ExecuteGetInternalLockedResource(TimeSpan?timeout, bool spin,
                                                                      CancellationToken token)
        {
            ThrowIfDisposingOrDisposed();
            //todo we are currently going to allow the infinite wait if desired ... not sure if this is a good idea but for now i'll leave it.
            //if (timeout == null && token == CancellationToken.None)
            //{
            //    throw new ArgumentException("If no timeout is specified, the cancellation token must not be none.");
            //}
            if (timeout.HasValue && timeout.Value <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(timeout), timeout, @"Must be positive.");
            }

            return(timeout == null
                ? AtomicLockedResource.CreateInternalLockedResource(this, token, spin)
                : AtomicLockedResource.CreateInternalLockedResource(this, timeout.Value, token, spin));
        }