示例#1
0
        public static async Task DependendRequestsExample(Math.MathClient client)
        {
            var numbers = new List <Num>
            {
                new Num {
                    Num_ = 1
                },
                new Num {
                    Num_ = 2
                },
                new Num {
                    Num_ = 3
                }
            };

            Num sum;

            using (var sumCall = client.Sum())
            {
                await sumCall.RequestStream.WriteAllAsync(numbers);

                sum = await sumCall.ResponseAsync;
            }

            DivReply result = await client.DivAsync(new DivArgs { Dividend = sum.Num_, Divisor = numbers.Count });

            Console.WriteLine("Avg Result: " + result);
        }
示例#2
0
        public static void DivExample(Math.MathClient client)
        {
            DivReply result = client.Div(new DivArgs {
                Dividend = 10, Divisor = 3
            });

            Console.WriteLine("Div Result: " + result);
        }
示例#3
0
 /// <summary>
 /// Shows how to handle a call ending with non-OK status.
 /// </summary>
 public static async Task HandleErrorExample(Math.MathClient client)
 {
     try
     {
         DivReply result = await client.DivAsync(new DivArgs { Dividend = 5, Divisor = 0 });
     }
     catch (RpcException ex)
     {
         Console.WriteLine(string.Format("RPC ended with status {0}", ex.Status));
     }
 }
示例#4
0
        public static async Task DivAsyncExample(Math.MathClient client)
        {
            DivReply result = await client.DivAsync(new DivArgs { Dividend = 4, Divisor = 5 });

            Console.WriteLine("DivAsync Result: " + result);
        }