Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new SimpleStockTicker.SimpleStockTickerClient(channel);

            var request = new SubscribeRequest();

            request.Symbols.AddRange(args);
            using var stream = client.Subscribe(request);

            var tokenSource = new CancellationTokenSource();
            var task        = DisplayAsync(stream.ResponseStream, tokenSource.Token);

            WaitForExitKey();

            tokenSource.Cancel();
            await task;
        }
Ejemplo n.º 2
0
        static async Task Main(string[] args)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new SimpleStockTicker.SimpleStockTickerClient(channel);

            var request = new SubscribeRequest();

            request.Symbols.AddRange(new[] { "MSFT", "AAPL" });
            using var stream = client.Subscribe(request);

            var tokenSource = new CancellationTokenSource();
            var task        = DisplayAsync(stream.ResponseStream, tokenSource.Token);

            WaitForExitKey();

            tokenSource.Cancel();
            await task;
        }