private async void btnOk_Click(object sender, RoutedEventArgs e) { btnOk.IsEnabled = false; CancellationToken = new CancellationTokenSource(); WriteLine($" Stream started (id: {ID})"); using var streamCall = Client.ClientTimeStream(cancellationToken: CancellationToken.Token); try { Value.Value = "evaluating..."; for (int i = 0; i < 10; i++) { await streamCall.RequestStream.WriteAsync(new GrpcServer.StreamData { Tikcs = DateTime.Now.Ticks }); await Task.Delay(1000); } await streamCall.RequestStream.CompleteAsync(); var result = await streamCall.ResponseAsync; Value.Value = result.Message; WriteLine($" Stream completed (id: {ID})"); btnOk.IsEnabled = true; } catch (Exception ex) { btnOk.IsEnabled = true; WriteLine(ex.Message); } }