public void EndWriteMessage(IAsyncResult asyncResult)
{
if (asyncResult == null)
{
throw new ArgumentNullException(nameof(asyncResult));
}
WorkerAsyncResult workerResult = asyncResult as WorkerAsyncResult;
if (workerResult != null)
{
if (!workerResult.InternalPeekCompleted)
{
workerResult.InternalWaitForCompletion();
}
if (workerResult.Result is Exception)
{
throw (Exception)(workerResult.Result);
}
}
else
{
_transport.EndWrite(asyncResult);
}
}
}