コード例 #1
0
ファイル: RequestManager.cs プロジェクト: suicvne/Luigibot
 public void QueueOperation(string key, RequestOperation operation)
 {
     if (PendingOperations.ContainsKey(key))
     {
         throw new InvalidOperationException("Operation is already pending.");
     }
     PendingOperations.Add(key, operation);
 }
コード例 #2
0
ファイル: RequestManager.cs プロジェクト: TETYYS/ChatSharp
        public async ValueTask ExecuteOperation(string key, object State)
        {
            RequestOperation req;

            if (PendingOperations.TryGetValue(key, out req))
            {
                Interlocked.Increment(ref req.RefCount);
                await req.Ev.WaitAsync();

                return;
            }

            if (!PendingOperations.TryAdd(key, req = new RequestOperation(State)))
            {
                throw new ArgumentException("An item with the same key has already been added");
            }

            await req.Ev.WaitAsync();
        }
コード例 #3
0
ファイル: RequestManager.cs プロジェクト: RockyTV/ChatSharp
 public void QueueOperation(string key, RequestOperation operation)
 {
     if (PendingOperations.ContainsKey(key))
         throw new InvalidOperationException("Operation is already pending.");
     PendingOperations.Add(key, operation);
 }