FtpWebRequest.EndGetResponse(IAsyncResult) Yöntem
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
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
- asyncResult
- IAsyncResult
IAsyncResult İşlem başlatıldığında döndürülen.
Örnek WebResponse içeren bir FtpWebResponse başvuru. Bu nesne, FTP sunucusunun isteğe verdiği yanıtı içerir.
asyncResult
, null
değeridir.
asyncResult
çağrılarak BeginGetResponse(AsyncCallback, Object)elde edilemedi.
Bu yöntem tarafından asyncResult
tanımlanan işlem için zaten çağrıldı.
HTTP ara sunucusu kullanılarak bir hata oluştu.
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 bir 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();
}
}
Yöntem çağrıldığında EndGetResponse işlem tamamlanmamışsa, EndGetResponse işlem tamamlanana kadar engeller. Engellemeyi önlemek için çağrısı EndGetResponseyapmadan IsCompleted önce özelliğini denetleyin.
"Özel durumlar" EndGetResponse bölümünde 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 bkz. .NET Framework'te Ağ İzleme.
Bu yöntem ağ trafiği oluşturur.
Ürün | Sürümler |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET geri bildirimi
.NET, açık kaynak bir projedir. Geri bildirim sağlamak için bir bağlantı seçin: