Microsoft.R.Host.Client.RHost.SendAsync C# (CSharp) Method

SendAsync() private method

private SendAsync ( Message message, CancellationToken ct ) : Task
message Message
ct System.Threading.CancellationToken
return Task
        private async Task SendAsync(Message message, CancellationToken ct) {
            TaskUtilities.AssertIsOnBackgroundThread();

            _log.Request(message.ToString(), _rLoopDepth);

            try {
                await _transport.SendAsync(message, ct);
            } catch (MessageTransportException ex) when (ct.IsCancellationRequested) {
                // Network errors during cancellation are expected, but should not be exposed to clients.
                throw new OperationCanceledException(new OperationCanceledException().Message, ex);
            } catch (MessageTransportException ex) {
                throw new RHostDisconnectedException(ex.Message, ex);
            }
        }

Usage Example

            public static async Task <CreateBlobRequest> CreateAsync(RHost host, CancellationToken cancellationToken)
            {
                var message = host.CreateRequestMessage("?CreateBlob", new JArray());
                var request = new CreateBlobRequest(host, message, cancellationToken);

                await host.SendAsync(message, cancellationToken);

                return(request);
            }
All Usage Examples Of Microsoft.R.Host.Client.RHost::SendAsync