UploadDataCompletedEventArgs Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menyediakan data untuk peristiwa tersebut UploadDataCompleted .
public ref class UploadDataCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class UploadDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type UploadDataCompletedEventArgs = class
inherit AsyncCompletedEventArgs
Public Class UploadDataCompletedEventArgs
Inherits AsyncCompletedEventArgs
- Warisan
Contoh
Contoh kode berikut menunjukkan pengunggahan data secara asinkron.
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
Metode berikut dipanggil ketika unggahan selesai.
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
Keterangan
Instans kelas ini diteruskan ke UploadDataCompletedEventHandler.
Properti
Cancelled |
Mendapatkan nilai yang menunjukkan apakah operasi asinkron telah dibatalkan. (Diperoleh dari AsyncCompletedEventArgs) |
Error |
Mendapatkan nilai yang menunjukkan kesalahan mana yang terjadi selama operasi asinkron. (Diperoleh dari AsyncCompletedEventArgs) |
Result |
Mendapatkan balasan server ke operasi pengunggahan data yang dimulai dengan memanggil UploadDataAsync metode . |
UserState |
Mendapatkan pengidentifikasi unik untuk tugas asinkron. (Diperoleh dari AsyncCompletedEventArgs) |
Metode
Equals(Object) |
Menentukan apakah objek yang ditentukan sama dengan objek saat ini. (Diperoleh dari Object) |
GetHashCode() |
Berfungsi sebagai fungsi hash default. (Diperoleh dari Object) |
GetType() |
Mendapatkan instans Type saat ini. (Diperoleh dari Object) |
MemberwiseClone() |
Membuat salinan dangkal dari yang saat ini Object. (Diperoleh dari Object) |
RaiseExceptionIfNecessary() |
Meningkatkan pengecualian yang disediakan pengguna jika operasi asinkron gagal. (Diperoleh dari AsyncCompletedEventArgs) |
ToString() |
Mengembalikan string yang mewakili objek saat ini. (Diperoleh dari Object) |