public override void EndWrite(IAsyncResult asyncResult)
{
InternalAsyncResult internalAsyncResult = asyncResult as InternalAsyncResult;
if (internalAsyncResult == null)
{
throw new ArgumentException("AsyncResult object was not obtained from SslStream.BeginWrite", "asyncResult");
}
if (!internalAsyncResult.IsCompleted)
{
if (!internalAsyncResult.AsyncWaitHandle.WaitOne(WaitTimeOut, false))
{
throw new IOException("Failed to complete the Write operation");
}
}
if (internalAsyncResult.CompletedWithError)
{
throw internalAsyncResult.AsyncException;
}
}