diff --git a/src/csharp/Grpc.Examples.MathClient/MathClient.cs b/src/csharp/Grpc.Examples.MathClient/MathClient.cs index f969d3aa838..ac13eddcee3 100644 --- a/src/csharp/Grpc.Examples.MathClient/MathClient.cs +++ b/src/csharp/Grpc.Examples.MathClient/MathClient.cs @@ -13,32 +13,30 @@ // See the License for the specific language governing permissions and // limitations under the License. #endregion -using System; -using System.Runtime.InteropServices; -using System.Threading; +using System.Threading.Tasks; using Grpc.Core; namespace Math { class MathClient { - public static void Main(string[] args) + public static async Task Main(string[] args) { var channel = new Channel("127.0.0.1", 23456, ChannelCredentials.Insecure); Math.MathClient client = new Math.MathClient(channel); MathExamples.DivExample(client); - MathExamples.DivAsyncExample(client).Wait(); + await MathExamples.DivAsyncExample(client); - MathExamples.FibExample(client).Wait(); + await MathExamples.FibExample(client); - MathExamples.SumExample(client).Wait(); + await MathExamples.SumExample(client); - MathExamples.DivManyExample(client).Wait(); + await MathExamples.DivManyExample(client); - MathExamples.DependendRequestsExample(client).Wait(); + await MathExamples.DependentRequestsExample(client); - channel.ShutdownAsync().Wait(); + await channel.ShutdownAsync(); } } } diff --git a/src/csharp/Grpc.Examples.MathServer/MathServer.cs b/src/csharp/Grpc.Examples.MathServer/MathServer.cs index 467a2689a0f..56cc1851fe1 100644 --- a/src/csharp/Grpc.Examples.MathServer/MathServer.cs +++ b/src/csharp/Grpc.Examples.MathServer/MathServer.cs @@ -15,8 +15,7 @@ #endregion using System; -using System.Runtime.InteropServices; -using System.Threading; +using System.Threading.Tasks; using Grpc.Core; namespace Math @@ -26,7 +25,7 @@ namespace Math const string Host = "0.0.0.0"; const int Port = 23456; - public static void Main(string[] args) + public static async Task Main(string[] args) { Server server = new Server { @@ -40,7 +39,7 @@ namespace Math Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); - server.ShutdownAsync().Wait(); + await server.ShutdownAsync(); } } } diff --git a/src/csharp/Grpc.Examples/MathExamples.cs b/src/csharp/Grpc.Examples/MathExamples.cs index b5d0b4e3987..d29c41a6f83 100644 --- a/src/csharp/Grpc.Examples/MathExamples.cs +++ b/src/csharp/Grpc.Examples/MathExamples.cs @@ -69,6 +69,7 @@ namespace Math new DivArgs { Dividend = 100, Divisor = 21 }, new DivArgs { Dividend = 7, Divisor = 2 } }; + using (var call = client.DivMany()) { await call.RequestStream.WriteAllAsync(divArgsList); @@ -76,7 +77,7 @@ namespace Math } } - public static async Task DependendRequestsExample(Math.MathClient client) + public static async Task DependentRequestsExample(Math.MathClient client) { var numbers = new List { diff --git a/src/csharp/Grpc.Examples/MathServiceImpl.cs b/src/csharp/Grpc.Examples/MathServiceImpl.cs index 0cc1b791372..2ef7629036c 100644 --- a/src/csharp/Grpc.Examples/MathServiceImpl.cs +++ b/src/csharp/Grpc.Examples/MathServiceImpl.cs @@ -16,9 +16,7 @@ #endregion -using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using Grpc.Core; using Grpc.Core.Utils;