Επεξεργασία

Κοινή χρήση μέσω


UploadDataCompletedEventArgs Class

Definition

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
Inheritance
UploadDataCompletedEventArgs

Examples

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

Remarks

Instances of this class are passed to the UploadDataCompletedEventHandler.

Properties

Cancelled

Gets a value indicating whether an asynchronous operation has been canceled.

(Inherited from AsyncCompletedEventArgs)
Error

Gets a value indicating which error occurred during an asynchronous operation.

(Inherited from AsyncCompletedEventArgs)
Result

Gets the server reply to a data upload operation started by calling an UploadDataAsync method.

UserState

Gets the unique identifier for the asynchronous task.

(Inherited from AsyncCompletedEventArgs)

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RaiseExceptionIfNecessary()

Raises a user-supplied exception if an asynchronous operation failed.

(Inherited from AsyncCompletedEventArgs)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to