DownloadStringCompletedEventArgs DownloadStringCompletedEventArgs DownloadStringCompletedEventArgs DownloadStringCompletedEventArgs Class

Definizione

Fornisce dati per l'evento DownloadStringCompleted.Provides data for the DownloadStringCompleted event.

public ref class DownloadStringCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class DownloadStringCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type DownloadStringCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class DownloadStringCompletedEventArgs
Inherits AsyncCompletedEventArgs
Ereditarietà
DownloadStringCompletedEventArgsDownloadStringCompletedEventArgsDownloadStringCompletedEventArgsDownloadStringCompletedEventArgs

Esempi

Il codice seguente viene illustrato il download di una stringa in modo asincrono.The following code example demonstrates downloading a string asynchronously.

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

Il metodo seguente viene chiamato al termine del download.The following method is called when the download completes.

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

Commenti

Le istanze di questa classe vengono passate al DownloadStringCompletedEventHandler.Instances of this class are passed to the DownloadStringCompletedEventHandler.

Proprietà

Cancelled Cancelled Cancelled Cancelled

Ottiene un valore che indica se un'operazione asincrona è stata annullata.Gets a value indicating whether an asynchronous operation has been canceled.

(Inherited from AsyncCompletedEventArgs)
Error Error Error Error

Ottiene un valore che indica l'errore verificatosi durante un'operazione asincrona.Gets a value indicating which error occurred during an asynchronous operation.

(Inherited from AsyncCompletedEventArgs)
Result Result Result Result

Ottiene i dati scaricati da un metodo DownloadStringAsync.Gets the data that is downloaded by a DownloadStringAsync method.

UserState UserState UserState UserState

Ottiene l’identificatore univoco per l'attività asincrona.Gets the unique identifier for the asynchronous task.

(Inherited from AsyncCompletedEventArgs)

Metodi

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Inherited from Object)
RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary()

Genera un'eccezione fornita dall'utente in caso di errore in un'operazione asincrona.Raises a user-supplied exception if an asynchronous operation failed.

(Inherited from AsyncCompletedEventArgs)
ToString() ToString() ToString() ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Inherited from Object)

Si applica a