Esempio n. 1
0
        /// <summary>
        /// Send a command to debugger.
        /// </summary>
        /// <param name="command">Command.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        public async Task SendRequestAsync(DebuggerCommand command, CancellationToken cancellationToken = new CancellationToken())
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (!_connection.Connected)
            {
                throw new Exception("DebuggerConnection not connected");
            }
            try
            {
                TaskCompletionSource <JObject> promise = _messages.GetOrAdd(command.Id, i => new TaskCompletionSource <JObject>());
                _connection.SendMessage(command.ToString());
                cancellationToken.ThrowIfCancellationRequested();

                cancellationToken.Register(() => promise.TrySetCanceled(), false);

                JObject response = await promise.Task.ConfigureAwait(false);

                cancellationToken.ThrowIfCancellationRequested();

                command.ProcessResponse(response);
            } finally {
                TaskCompletionSource <JObject> promise;
                _messages.TryRemove(command.Id, out promise);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Send a command to debugger.
        /// </summary>
        /// <param name="command">Command.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        public async Task SendRequestAsync(DebuggerCommand command, CancellationToken cancellationToken = new CancellationToken())
        {
            cancellationToken.ThrowIfCancellationRequested();

            try
            {
                var promise = this._messages.GetOrAdd(command.Id, i => new TaskCompletionSource <JObject>());
                this._connection.SendMessage(command.ToString());
                cancellationToken.ThrowIfCancellationRequested();

                cancellationToken.Register(() => promise.TrySetCanceled(), false);

                var response = await promise.Task.ConfigureAwait(false);

                cancellationToken.ThrowIfCancellationRequested();

                command.ProcessResponse(response);
            }
            finally
            {
                this._messages.TryRemove(command.Id, out var promise);
            }
        }
Esempio n. 3
0
 public void ImportDebuggerCommand(string id, DebuggerCommand command)
 {
     debugger.debuggerCommands.Add(id, command);
 }