static async Task Main(string[] args) { Channel channel = new Channel(target, ChannelCredentials.Insecure); await channel.ConnectAsync().ContinueWith((task) => { if (task.Status == TaskStatus.RanToCompletion) { Console.WriteLine("The client connected successfully"); } }); var client = new PrimeNumberService.PrimeNumberServiceClient(channel); var request = new PrimeNumberDecompositionRequest() { Number = 120 }; var response = client.PrimeNumberDecomposition(request); while (await response.ResponseStream.MoveNext()) { Console.WriteLine(response.ResponseStream.Current.PrimeFactor); await Task.Delay(200); } channel.ShutdownAsync().Wait(); Console.ReadKey(); }
//Server Streaming Prime public static async Task CalculatePrime(Channel channel) { var client = new PrimeNumberService.PrimeNumberServiceClient(channel); var request = new PrimeNumberDecompositionRequest() { Number = 120 }; var response = client.PrimeNumberDecomposition(request); while (await response.ResponseStream.MoveNext()) { Console.WriteLine(response.ResponseStream.Current.PrimeFactor); //One by one görmek için await Task.Delay(200); } }