public override WebResponse EndGetResponse(IAsyncResult asyncResult)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this);
try
{
// parameter validation
if (asyncResult == null)
{
throw new ArgumentNullException(nameof(asyncResult));
}
LazyAsyncResult castedAsyncResult = asyncResult as LazyAsyncResult;
if (castedAsyncResult == null)
{
throw new ArgumentException(SR.net_io_invalidasyncresult, nameof(asyncResult));
}
if (castedAsyncResult.EndCalled)
{
throw new InvalidOperationException(SR.Format(SR.net_io_invalidendcall, "EndGetResponse"));
}
castedAsyncResult.InternalWaitForCompletion();
castedAsyncResult.EndCalled = true;
CheckError();
}
catch (Exception exception)
{
if (NetEventSource.IsEnabled) NetEventSource.Error(this, exception);
throw;
}
finally
{
if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
}
return _ftpWebResponse;
}