Share via


DownloadStringCompletedEventArgs Sınıf

Tanım

DownloadStringCompleted olayı için veriler sağlar.

public ref class DownloadStringCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class DownloadStringCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type DownloadStringCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class DownloadStringCompletedEventArgs
Inherits AsyncCompletedEventArgs
Devralma
DownloadStringCompletedEventArgs

Örnekler

Aşağıdaki kod örneğinde bir dizenin zaman uyumsuz olarak indirilmesi gösterilmektedir.

// Sample call : DownloadStringInBackground2 ("http://www.contoso.com/GameScores.html");
void DownloadStringInBackground2( String^ address )
{
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);

   // Specify that the DownloadStringCallback2 method gets called
   // when the download completes.
   client->DownloadStringCompleted += gcnew DownloadStringCompletedEventHandler( DownloadStringCallback2 );
   client->DownloadStringAsync( uri );
}
// Sample call : DownloadStringInBackground2 ("http://www.contoso.com/GameScores.html");
public static void DownloadStringInBackground2(string address)
{
    WebClient client = new WebClient();
    Uri uri = new Uri(address);

    // Specify that the DownloadStringCallback2 method gets called
    // when the download completes.
    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCallback2);
    client.DownloadStringAsync(uri);
}
'  Sample call : DownloadStringInBackground2 ("http:' www.contoso.com/GameScores.html")
Public Shared Sub DownloadStringInBackground2(ByVal address As String)

    Dim client As WebClient = New WebClient()

    '  Specify that the DownloadStringCallback2 method gets called
    '  when the download completes.
    AddHandler client.DownloadStringCompleted, AddressOf DownloadStringCallback2
                Dim uri as Uri = New Uri(address)
    client.DownloadStringAsync(uri)
End Sub

İndirme tamamlandığında aşağıdaki yöntem çağrılır.

void DownloadStringCallback2( Object^ /*sender*/, DownloadStringCompletedEventArgs^ e )
{

   // If the request was not canceled and did not throw
   // an exception, display the resource.
   if (  !e->Cancelled && e->Error == nullptr )
   {
      String^ textString = dynamic_cast<String^>(e->Result);
      Console::WriteLine( textString );
   }
}
private static void DownloadStringCallback2(Object sender, DownloadStringCompletedEventArgs e)
{
    // If the request was not canceled and did not throw
    // an exception, display the resource.
    if (!e.Cancelled && e.Error == null)
    {
        string textString = (string)e.Result;

        Console.WriteLine(textString);
    }
}
Private Shared Sub DownloadStringCallback2(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)

    '  If the request was not canceled and did not throw
    '  an exception, display the resource.
    If e.Cancelled = False AndAlso e.Error Is Nothing Then

        Dim textString As String = CStr(e.Result)
        Console.WriteLine(textString)
    End If
End Sub

Açıklamalar

Bu sınıfın örnekleri öğesine DownloadStringCompletedEventHandlergeçirilir.

Özellikler

Cancelled

Zaman uyumsuz işlemin iptal edilip edilmediğini belirten bir değer alır.

(Devralındığı yer: AsyncCompletedEventArgs)
Error

Zaman uyumsuz bir işlem sırasında hangi hatanın oluştuğunu belirten bir değer alır.

(Devralındığı yer: AsyncCompletedEventArgs)
Result

Bir DownloadStringAsync yöntem tarafından indirilen verileri alır.

UserState

Zaman uyumsuz görevin benzersiz tanımlayıcısını alır.

(Devralındığı yer: AsyncCompletedEventArgs)

Yöntemler

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
RaiseExceptionIfNecessary()

Zaman uyumsuz bir işlem başarısız olursa kullanıcı tarafından sağlanan bir özel durum oluşturur.

(Devralındığı yer: AsyncCompletedEventArgs)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır