Example #1
0
        private async void ProcessCommands()
        {
            while (!this.cancellationTokenSource.IsCancellationRequested)
            {
                try
                {
                    IReceivedCommand command = await this.client.ReadAsync(this.cancellationTokenSource.Token);

                    if (this.inflightCommands.ContainsKey(command.CommandId))
                    {
                        this.inflightCommands[command.CommandId].TrySetResult(command);
                    }

                    if (this.commandHandlers.ContainsKey(command.CommandId))
                    {
                        var handler = this.commandHandlers[command.CommandId];
                        handler.ForEach(c => c.Update(command));
                    }
                }
                catch (TaskCanceledException)
                {
                }
            }
        }
Example #2
0
 public void TrySetResult(IReceivedCommand command)
 {
     task.TrySetResult(command);
 }