DownloadDataCompletedEventArgs.Result DownloadDataCompletedEventArgs.Result DownloadDataCompletedEventArgs.Result DownloadDataCompletedEventArgs.Result Property

Definition

Ruft die von einer DownloadDataAsync-Methode heruntergeladenen Daten ab.Gets the data that is downloaded by a DownloadDataAsync method.

public:
 property cli::array <System::Byte> ^ Result { cli::array <System::Byte> ^ get(); };
public byte[] Result { get; }
member this.Result : byte[]
Public ReadOnly Property Result As Byte()

Eigenschaftswert

Byte[]

Ein Byte-Array, das die heruntergeladenen Daten enthält.A Byte array that contains the downloaded data.

Beispiele

Im folgenden Codebeispiel wird der Wert dieser Eigenschaft angezeigt.The following code example displays the value of this property.

void DownloadDataCallback( Object^ /*sender*/, DownloadDataCompletedEventArgs^ e )
{
   System::Threading::AutoResetEvent^ waiter = dynamic_cast<System::Threading::AutoResetEvent^>(e->UserState);
   try
   {
      
      // If the request was not canceled and did not throw
      // an exception, display the resource.
      if (  !e->Cancelled && e->Error == nullptr )
      {
         array<Byte>^data = dynamic_cast<array<Byte>^>(e->Result);
         String^ textData = System::Text::Encoding::UTF8->GetString( data );
         Console::WriteLine( textData );
      }
   }
   finally
   {
      
      // Let the main application thread resume.
      waiter->Set();
   }

}


private static void DownloadDataCallback (Object sender, DownloadDataCompletedEventArgs e)
{
    System.Threading.AutoResetEvent waiter = (System.Threading.AutoResetEvent)e.UserState;

    try
    {
        // If the request was not canceled and did not throw
        // an exception, display the resource.
        if (!e.Cancelled && e.Error == null)
        {
            byte[] data = (byte[])e.Result;
            string textData = System.Text.Encoding.UTF8.GetString (data);

            Console.WriteLine (textData);
        }
    }
    finally
    {
        // Let the main application thread resume.
        waiter.Set ();
    }
}

Private Shared Sub DownloadDataCallback(ByVal sender As Object, ByVal e As DownloadDataCompletedEventArgs)

    Dim waiter As System.Threading.AutoResetEvent = CType(e.UserState, System.Threading.AutoResetEvent)

    Try

        '  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 data() As Byte = CType(e.Result, Byte())
            Dim textData As String = System.Text.Encoding.UTF8.GetString(data)

            Console.WriteLine(textData)
        End If
    Finally

        '  Let the main application thread resume.
        waiter.Set()
    End Try
End Sub

Hinweise

Sie sollten die Error -Eigenschaft Cancelled und die-Eigenschaft überprüfen, bevor Sie die von dieser Eigenschaft zurückgegebenen Daten verwenden.You should check the Error and Cancelled properties before using the data that is returned by this property. Wenn der Error Wert der Eigenschaft ein Exception Objekt oder der Wert Cancelled der Eigenschaft ist true, wurde der asynchrone Vorgang nicht ordnungsgemäß ausgeführt, und Result der Eigenschafts Wert ist nicht gültig.If the Error property's value is an Exception object or the Cancelled property's value is true, the asynchronous operation did not complete correctly and the Result property's value will not be valid.

Gilt für: