UploadDataCompletedEventArgs UploadDataCompletedEventArgs UploadDataCompletedEventArgs UploadDataCompletedEventArgs Class

Определение

Предоставляет данные для события 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
Наследование
UploadDataCompletedEventArgsUploadDataCompletedEventArgsUploadDataCompletedEventArgsUploadDataCompletedEventArgs

Примеры

В следующем примере кода демонстрируется асинхронная отправка данных.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

При завершении передачи вызывается следующий метод.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

Комментарии

Экземпляры этого класса передаются в UploadDataCompletedEventHandler.Instances of this class are passed to the UploadDataCompletedEventHandler.

Свойства

Cancelled Cancelled Cancelled Cancelled

Возвращает значение, показывающее, была ли отменена асинхронная операция.Gets a value indicating whether an asynchronous operation has been canceled.

(Inherited from AsyncCompletedEventArgs)
Error Error Error Error

Возвращает значение, показывающее, какая ошибка произошла в течение асинхронной операции.Gets a value indicating which error occurred during an asynchronous operation.

(Inherited from AsyncCompletedEventArgs)
Result Result Result Result

Возвращает ответ сервера на операцию отправки данных, начатую посредством вызова метода UploadDataAsync.Gets the server reply to a data upload operation started by calling an UploadDataAsync method.

UserState UserState UserState UserState

Возвращает уникальный идентификатор для асинхронной задачи.Gets the unique identifier for the asynchronous task.

(Inherited from AsyncCompletedEventArgs)

Методы

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Определяет, равен ли заданный объект текущему объекту.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Служит хэш-функцией по умолчанию.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Возвращает объект Type для текущего экземпляра.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Создает неполную копию текущего объекта Object.Creates a shallow copy of the current Object.

(Inherited from Object)
RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary()

Вызывает предоставленное пользователем исключение в случае неудачного выполнения асинхронной операции.Raises a user-supplied exception if an asynchronous operation failed.

(Inherited from AsyncCompletedEventArgs)
ToString() ToString() ToString() ToString()

Возвращает строку, представляющую текущий объект.Returns a string that represents the current object.

(Inherited from Object)

Применяется к