Share via


FtpWebRequest.EndGetResponse(IAsyncResult) Yöntem

Tanım

ile BeginGetResponse(AsyncCallback, Object)başlatılan bekleyen zaman uyumsuz işlemi sonlandırır.

public:
 override System::Net::WebResponse ^ EndGetResponse(IAsyncResult ^ asyncResult);
public override System.Net.WebResponse EndGetResponse (IAsyncResult asyncResult);
override this.EndGetResponse : IAsyncResult -> System.Net.WebResponse
Public Overrides Function EndGetResponse (asyncResult As IAsyncResult) As WebResponse

Parametreler

asyncResult
IAsyncResult

İşlem IAsyncResult başlatıldığında döndürülen.

Döndürülenler

Örnek WebResponse içeren bir FtpWebResponse başvuru. Bu nesne, FTP sunucusunun isteğe verdiği yanıtı içerir.

Özel durumlar

asyncResult, null değeridir.

asyncResult çağrılarak BeginGetResponse(AsyncCallback, Object)elde edilemedi.

Bu yöntem tarafından asyncResulttanımlanan işlem için zaten çağrıldı.

HTTP proxy'si kullanılırken bir hata oluştu.

Örnekler

Aşağıdaki kod örneği, yanıt almak için zaman uyumsuz bir işlemi sonlandırmayı gösterir. Bu kod örneği, sınıfa genel bakış için FtpWebRequest sağlanan daha büyük bir örneğin parçasıdır.

// The EndGetResponseCallback method  
// completes a call to BeginGetResponse.
static void EndGetResponseCallback( IAsyncResult^ ar )
{
   FtpState^ state = dynamic_cast<FtpState^>(ar->AsyncState);
   FtpWebResponse ^ response = nullptr;
   try
   {
      response = dynamic_cast<FtpWebResponse^>(state->Request->EndGetResponse( ar ));
      response->Close();
      state->StatusDescription = response->StatusDescription;

      // Signal the main application thread that 
      // the operation is complete.
      state->OperationComplete->Set();
   }
   // Return exceptions to the main application thread.
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Error getting response." );
      state->OperationException = e;
      state->OperationComplete->Set();
   }
}
// The EndGetResponseCallback method
// completes a call to BeginGetResponse.
private static void EndGetResponseCallback(IAsyncResult ar)
{
    FtpState state = (FtpState) ar.AsyncState;
    FtpWebResponse response = null;
    try
    {
        response = (FtpWebResponse) state.Request.EndGetResponse(ar);
        response.Close();
        state.StatusDescription = response.StatusDescription;
        // Signal the main application thread that
        // the operation is complete.
        state.OperationComplete.Set();
    }
    // Return exceptions to the main application thread.
    catch (Exception e)
    {
        Console.WriteLine ("Error getting response.");
        state.OperationException = e;
        state.OperationComplete.Set();
    }
}

Açıklamalar

Yöntem çağrıldığında EndGetResponse işlem tamamlanmamışsa, EndGetResponse işlem tamamlanana kadar engeller. Engellemeyi önlemek için çağırmadan EndGetResponseönce özelliğini denetleyinIsCompleted.

"Özel durumlar" EndGetResponse içinde belirtilen özel durumlara ek olarak, sunucuyla iletişim kurulurken oluşan özel durumları yeniden oluşturur.

Not

Uygulamanızda ağ izlemeyi etkinleştirdiğinizde, bu üye izleme bilgilerini çıkarır. Daha fazla bilgi için .NET Framework ağ izleme bölümüne bakın.

Arayanlara Notlar

Bu yöntem ağ trafiği oluşturur.

Şunlara uygulanır

Ayrıca bkz.