Exemplo n.º 1
0
        public static async Task <KeyedSemaphoreSlimHandle <TKey> > WaitAsync <TKey>(this KeyedSemaphoreSlim <TKey> keyedSemaphoreSlim, IEnumerable <TKey> keys,
                                                                                     TimeSpan timeout, CancellationToken cancellationToken)
        {
            KeyedSemaphoreSlimHandle <TKey> handle = null;

            try
            {
                foreach (var key in keys)
                {
                    handle = await keyedSemaphoreSlim.WaitAsync(key, handle, timeout, cancellationToken);
                }
            }
            catch (Exception e)
            {
                handle?.Dispose();
                throw e;
            }

            return(handle);
        }
Exemplo n.º 2
0
 public static async Task <KeyedSemaphoreSlimHandle <TKey> > WaitAsync <TKey>(this KeyedSemaphoreSlim <TKey> keyedSemaphoreSlim, IEnumerable <TKey> keys)
 {
     return(await WaitAsync(keyedSemaphoreSlim, keys, Timeout.InfiniteTimeSpan, CancellationToken.None));
 }
Exemplo n.º 3
0
 internal KeyedSemaphoreSlimHandle(KeyedSemaphoreSlim <TKey> keyedSemaphoreSlim, TKey key, KeyedSemaphoreSlimHandle <TKey> parentHandle)
 {
     this.keyedSemaphoreSlim = keyedSemaphoreSlim;
     this.key          = key;
     this.parentHandle = parentHandle;
 }