UploadDataCompletedEventArgs Classe

Definição

Fornece dados para o evento de UploadDataCompleted .Provides data for the UploadDataCompleted event.

public ref class UploadDataCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class UploadDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type UploadDataCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class UploadDataCompletedEventArgs
Inherits AsyncCompletedEventArgs
Herança
UploadDataCompletedEventArgs

Exemplos

O exemplo de código a seguir demonstra o carregamento de dados de forma assíncrona.The following code example demonstrates asynchronously uploading data.

void UploadDataInBackground2( String^ address )
{
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);
   String^ text = "Time = 12:00am temperature = 50";
   array<Byte>^data = System::Text::Encoding::UTF8->GetBytes( text );
   String^ method = "POST";

   client->UploadDataCompleted += gcnew UploadDataCompletedEventHandler( UploadDataCallback2 );
   client->UploadDataAsync( uri, method, data );
}
public static void UploadDataInBackground2(string address)
{
    WebClient client = new WebClient();
    Uri uri = new Uri(address);
    string text = "Time = 12:00am temperature = 50";
    byte[] data = System.Text.Encoding.UTF8.GetBytes(text);
    string method = "POST";

    client.UploadDataCompleted += new UploadDataCompletedEventHandler(UploadDataCallback2);
    client.UploadDataAsync(uri, method, data);
}
Public Shared Sub UploadDataInBackground2(ByVal address As String)

    Dim client As WebClient = New WebClient()
    Dim text As String = "Time = 12:00am temperature = 50"
    Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(text)
    Dim method As String = "POST"

    AddHandler client.UploadDataCompleted, AddressOf UploadDataCallback2
    Dim uri as Uri = New Uri(address)
                client.UploadDataAsync(uri, method, data)
End Sub

O método a seguir é chamado quando o carregamento é concluído.The following method is called when the upload completes.

void UploadDataCallback2( Object^ /*sender*/, UploadDataCompletedEventArgs^ e )
{
   array<Byte>^data = dynamic_cast<array<Byte>^>(e->Result);
   String^ reply = System::Text::Encoding::UTF8->GetString( data );
   Console::WriteLine( reply );
}
private static void UploadDataCallback2(Object sender, UploadDataCompletedEventArgs e)
{
    byte[] data = (byte[])e.Result;
    string reply = System.Text.Encoding.UTF8.GetString(data);

    Console.WriteLine(reply);
}
Private Shared Sub UploadDataCallback2(ByVal sender As Object, ByVal e As UploadDataCompletedEventArgs)

    Dim data() As Byte = CType(e.Result, Byte())
    Dim reply As String = System.Text.Encoding.UTF8.GetString(data)

    Console.WriteLine(reply)
End Sub

Comentários

As instâncias dessa classe são passadas para o UploadDataCompletedEventHandler .Instances of this class are passed to the UploadDataCompletedEventHandler.

Propriedades

Cancelled

Obtém um valor que indica se uma operação assíncrona foi cancelada.Gets a value indicating whether an asynchronous operation has been canceled.

(Herdado de AsyncCompletedEventArgs)
Error

Obtém um valor que indica qual erro ocorreu durante uma operação assíncrona.Gets a value indicating which error occurred during an asynchronous operation.

(Herdado de AsyncCompletedEventArgs)
Result

Obtém a resposta do servidor para uma operação de upload de dados iniciada chamando um método UploadDataAsync.Gets the server reply to a data upload operation started by calling an UploadDataAsync method.

UserState

Obtém o identificador exclusivo para a tarefa assíncrona.Gets the unique identifier for the asynchronous task.

(Herdado de AsyncCompletedEventArgs)

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
RaiseExceptionIfNecessary()

Gera uma exceção fornecida pelo usuário se uma operação assíncrona falhou.Raises a user-supplied exception if an asynchronous operation failed.

(Herdado de AsyncCompletedEventArgs)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Aplica-se a