示例#1
0
        /// <summary>
        /// 指定したキーで待機します。
        /// </summary>
        /// <param name="key">待機するキー</param>
        public static async Task WaitAsync(string key)
        {
            await LockSemaphore.WaitAsync();

            try
            {
                if (!Semaphores.ContainsKey(key))
                {
                    Semaphores.Add(key, new SemaphoreSlim(1, 1));
                }
            }
            finally
            {
                LockSemaphore.Release();
            }
            await Semaphores[key].WaitAsync();
        }
示例#2
0
 private void InternalUnlock(Task t)
 => LockSemaphore.Release();