DownloadStringCompletedEventArgs 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 DownloadStringCompleted .
public ref class DownloadStringCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class DownloadStringCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type DownloadStringCompletedEventArgs = class
inherit AsyncCompletedEventArgs
Public Class DownloadStringCompletedEventArgs
Inherits AsyncCompletedEventArgs
- Warisan
Contoh
Contoh kode berikut menunjukkan pengunduhan string secara asinkron.
// Sample call : DownloadStringInBackground2 ("http://www.contoso.com/GameScores.html");
void DownloadStringInBackground2( String^ address )
{
WebClient^ client = gcnew WebClient;
Uri ^uri = gcnew Uri(address);
// Specify that the DownloadStringCallback2 method gets called
// when the download completes.
client->DownloadStringCompleted += gcnew DownloadStringCompletedEventHandler( DownloadStringCallback2 );
client->DownloadStringAsync( uri );
}
// Sample call : DownloadStringInBackground2 ("http://www.contoso.com/GameScores.html");
public static void DownloadStringInBackground2(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
// Specify that the DownloadStringCallback2 method gets called
// when the download completes.
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCallback2);
client.DownloadStringAsync(uri);
}
' Sample call : DownloadStringInBackground2 ("http:' www.contoso.com/GameScores.html")
Public Shared Sub DownloadStringInBackground2(ByVal address As String)
Dim client As WebClient = New WebClient()
' Specify that the DownloadStringCallback2 method gets called
' when the download completes.
AddHandler client.DownloadStringCompleted, AddressOf DownloadStringCallback2
Dim uri as Uri = New Uri(address)
client.DownloadStringAsync(uri)
End Sub
Metode berikut dipanggil ketika pengunduhan selesai.
void DownloadStringCallback2( Object^ /*sender*/, DownloadStringCompletedEventArgs^ e )
{
// If the request was not canceled and did not throw
// an exception, display the resource.
if ( !e->Cancelled && e->Error == nullptr )
{
String^ textString = dynamic_cast<String^>(e->Result);
Console::WriteLine( textString );
}
}
private static void DownloadStringCallback2(Object sender, DownloadStringCompletedEventArgs e)
{
// If the request was not canceled and did not throw
// an exception, display the resource.
if (!e.Cancelled && e.Error == null)
{
string textString = (string)e.Result;
Console.WriteLine(textString);
}
}
Private Shared Sub DownloadStringCallback2(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)
' 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 textString As String = CStr(e.Result)
Console.WriteLine(textString)
End If
End Sub
Keterangan
Instans kelas ini diteruskan ke DownloadStringCompletedEventHandler.
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 data yang diunduh dengan DownloadStringAsync 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) |