diff --git a/src/DotNetty.Handlers/Tls/TlsHandler.cs b/src/DotNetty.Handlers/Tls/TlsHandler.cs index a4c9da02..b7e9b194 100644 --- a/src/DotNetty.Handlers/Tls/TlsHandler.cs +++ b/src/DotNetty.Handlers/Tls/TlsHandler.cs @@ -959,15 +959,7 @@ public override int EndRead(IAsyncResult asyncResult) Debug.Assert(this.readCompletionSource == null || this.readCompletionSource.Task == asyncResult); Contract.Assert(!((Task)asyncResult).IsCanceled); - try - { - return ((Task)asyncResult).Result; - } - catch (AggregateException ex) - { - ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); - throw; // unreachable - } + return ((Task)asyncResult).GetAwaiter().GetResult(); } IAsyncResult PrepareSyncReadResult(int readBytes, object state) @@ -1051,15 +1043,7 @@ public override void EndWrite(IAsyncResult asyncResult) return; } - try - { - ((Task)asyncResult).Wait(); - } - catch (AggregateException ex) - { - ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); - throw; - } + ((Task)asyncResult).GetAwaiter().GetResult(); } #endif