AsyncCompletedEventHandler Delegado

Definición

Representa el método que controlará el evento MethodName Completed de una operación asincrónica.Represents the method that will handle the MethodNameCompleted event of an asynchronous operation.

public delegate void AsyncCompletedEventHandler(System::Object ^ sender, AsyncCompletedEventArgs ^ e);
public delegate void AsyncCompletedEventHandler(object sender, AsyncCompletedEventArgs e);
public delegate void AsyncCompletedEventHandler(object? sender, AsyncCompletedEventArgs e);
type AsyncCompletedEventHandler = delegate of obj * AsyncCompletedEventArgs -> unit
Public Delegate Sub AsyncCompletedEventHandler(sender As Object, e As AsyncCompletedEventArgs)

Parámetros

sender
Object

Origen del evento.The source of the event.

e
AsyncCompletedEventArgs

Objeto AsyncCompletedEventArgs que contiene los datos del evento.An AsyncCompletedEventArgs that contains the event data.

Ejemplos

Para obtener un ejemplo de código del AsyncCompletedEventHandler delegado, vea el ejemplo de la System.ComponentModel.AsyncCompletedEventArgs clase.For a code example of the AsyncCompletedEventHandler delegate, see the example in the System.ComponentModel.AsyncCompletedEventArgs class.

Comentarios

Cuando se crea un delegado AsyncCompletedEventHandler, se identifica el método que controlará el evento.When you create an AsyncCompletedEventHandler delegate, you identify the method that will handle the event. Para asociar el evento al controlador, se debe agregar una instancia del delegado al evento.To associate the event with your event handler, add an instance of the delegate to the event. Se llama al método de control de eventos cada vez que se produce el evento, a menos que se quite el delegado.The event-handler method is called whenever the event occurs, unless you remove the delegate. Para obtener más información sobre los delegados de controladores de eventos, vea controlar y provocar eventos.For more information about event-handler delegates, see Handling and Raising Events.

Para un método asincrónico, denominado MethodName, en el componente, tendrá un evento MethodName correspondiente Completed y una clase MethodName opcional CompletedEventArgs .For an asynchronous method, called MethodName, in your component, you will have a corresponding MethodNameCompleted event, and an optional MethodNameCompletedEventArgs class.

Para un componente que admite varias invocaciones simultáneas de sus métodos asincrónicos, el cliente puede proporcionar un token único o un identificador de tarea para distinguir qué tarea asincrónica está generando eventos concretos.For a component that supports multiple concurrent invocations of its asynchronous methods, the client can supply a unique token, or task ID, to distinguish which asynchronous task is raising particular events. El cliente AsyncCompletedEventHandler puede leer la AsyncCompletedEventArgs.UserState propiedad para determinar qué tarea informa de la finalización.The client's AsyncCompletedEventHandler can read the AsyncCompletedEventArgs.UserState property to determine which task is reporting completion. La implementación de debe utilizar System.ComponentModel.AsyncOperationManager para crear un System.ComponentModel.AsyncOperation que asocie los identificadores de tarea del cliente con tareas asincrónicas pendientes.Your implementation should use the System.ComponentModel.AsyncOperationManager to create an System.ComponentModel.AsyncOperation that associates the client's task IDs with pending asynchronous tasks.

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.Gets an object that represents the method represented by the specified delegate.

Se aplica a

Consulte también