Refactoring test server/client to use async/await more consistently
diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs
index 471d6c8..65458d6 100644
--- a/test/netstd/Server/TestServer.cs
+++ b/test/netstd/Server/TestServer.cs
@@ -500,13 +500,11 @@
return Task.FromResult(result);
}
- public Task testOneway(int secondsToSleep, CancellationToken cancellationToken)
+ public async Task testOneway(int secondsToSleep, CancellationToken cancellationToken)
{
logger.Invoke("testOneway({0}), sleeping...", secondsToSleep);
- Task.Delay(secondsToSleep * 1000, cancellationToken).GetAwaiter().GetResult();
+ await Task.Delay(secondsToSleep * 1000, cancellationToken);
logger.Invoke("testOneway finished");
-
- return Task.CompletedTask;
}
}
@@ -543,7 +541,7 @@
return cert;
}
- public static int Execute(List<string> args)
+ public static async Task<int> Execute(List<string> args)
{
using (var loggerFactory = new LoggerFactory()) //.AddConsole().AddDebug();
{
@@ -648,7 +646,7 @@
(param.protocol == ProtocolChoice.Compact ? " with compact protocol" : "") +
(param.protocol == ProtocolChoice.Json ? " with json protocol" : "") +
"...");
- serverEngine.ServeAsync(CancellationToken.None).GetAwaiter().GetResult();
+ await serverEngine.ServeAsync(CancellationToken.None);
Console.ReadLine();
}
catch (Exception x)