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

Définition

Se produit lors d'une opération asynchrone de téléchargement de ressources.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 

Exemples

L’exemple de code suivant illustre la définition d’un gestionnaire d’événements pour cet événement.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

Remarques

Cet événement est déclenché chaque fois une opération asynchrone pour télécharger une ressource sous forme de chaîne se termine.This event is raised each time an asynchronous operation to download a resource as a string completes. Ces opérations sont démarrées en appelant le DownloadStringAsync méthodes.These operations are started by calling the DownloadStringAsync methods.

Le DownloadStringCompletedEventHandler est le délégué de cet événement.The DownloadStringCompletedEventHandler is the delegate for this event. Le DownloadStringCompletedEventArgs classe fournit le Gestionnaire d’événements avec les données d’événement.The DownloadStringCompletedEventArgs class provides the event handler with event data.

Pour plus d’informations sur la façon de gérer les événements, consultez gestion et déclenchement d’événements.For more information about how to handle events, see Handling and Raising Events.

S’applique à