WebClient.DownloadStringCompleted WebClient.DownloadStringCompleted WebClient.DownloadStringCompleted WebClient.DownloadStringCompleted Event

Definizione

Si verifica al completamento di un'operazione asincrona di download di risorse.Occurs when an asynchronous resource-download operation completes.

public:
 event System::Net::DownloadStringCompletedEventHandler ^ DownloadStringCompleted;
public event System.Net.DownloadStringCompletedEventHandler DownloadStringCompleted;
member this.DownloadStringCompleted : System.Net.DownloadStringCompletedEventHandler 
Public Custom Event DownloadStringCompleted As DownloadStringCompletedEventHandler 

Esempi

Nell'esempio di codice riportato di seguito viene illustrata l'impostazione di un gestore eventi per questo evento.The following code example demonstrates setting an event handler for this event.

// 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

Commenti

Questo evento viene generato ogni volta che viene completata un'operazione asincrona di download di una risorsa come stringa.This event is raised each time an asynchronous operation to download a resource as a string completes. Queste operazioni vengono avviate chiamando i DownloadStringAsync metodi.These operations are started by calling the DownloadStringAsync methods.

DownloadStringCompletedEventHandler È il delegato per questo evento.The DownloadStringCompletedEventHandler is the delegate for this event. La DownloadStringCompletedEventArgs classe fornisce il gestore eventi con i dati dell'evento.The DownloadStringCompletedEventArgs class provides the event handler with event data.

Per altre informazioni su come gestire gli eventi, vedere la gestione e generazione di eventi.For more information about how to handle events, see Handling and Raising Events.

Si applica a