WaitCallback Delegado
Definición
Representa un método de devolución de llamada que debe ejecutar un subproceso del grupo de subprocesos.Represents a callback method to be executed by a thread pool thread.
public delegate void WaitCallback(System::Object ^ state);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void WaitCallback(object state);
type WaitCallback = delegate of obj -> unit
Public Delegate Sub WaitCallback(state As Object)
Parámetros
- state
- Object
Objeto que contiene la información que va a utilizar el método de devolución de llamada.An object containing information to be used by the callback method.
- Herencia
- Atributos
Comentarios
WaitCallbackrepresenta un método de devolución de llamada que desea ejecutar en ThreadPool un subproceso.WaitCallback represents a callback method that you want to execute on a ThreadPool thread. Cree el delegado pasando el método de devolución de llamada WaitCallback al constructor.Create the delegate by passing your callback method to the WaitCallback constructor. El método debe tener la firma que se muestra aquí.Your method must have the signature shown here.
Poner el método en cola para su ejecución WaitCallback pasando el ThreadPool.QueueUserWorkItemdelegado a.Queue the method for execution by passing the WaitCallback delegate to ThreadPool.QueueUserWorkItem. El método de devolución de llamada se ejecuta cuando un subproceso de grupo de subprocesos está disponible.The callback method executes when a thread pool thread becomes available.
Nota
Visual Basic usuarios pueden omitir WaitCallback el constructor y simplemente usar el AddressOf
operador al pasar el método de devolución QueueUserWorkItemde llamada a.Visual Basic users can omit the WaitCallback constructor, and simply use the AddressOf
operator when passing the callback method to QueueUserWorkItem. Visual Basic llama automáticamente al constructor de delegado correcto.Visual Basic automatically calls the correct delegate constructor.
Si desea pasar información al método de devolución de llamada, cree un objeto que contenga la información necesaria y páselo al QueueUserWorkItem(WaitCallback, Object) método como segundo argumento.If you want to pass information to the callback method, create an object that contains the necessary information and pass it to the QueueUserWorkItem(WaitCallback, Object) method as the second argument. Cada vez que se ejecuta el método de devolución state
de llamada, el parámetro contiene este objeto.Each time the callback method executes, the state
parameter contains this object.
Para obtener ejemplos que usan WaitCallback
el delegado, vea ThreadPool.QueueUserWorkItem el método.For examples that use the WaitCallback
delegate, see the ThreadPool.QueueUserWorkItem method.
Para obtener más información sobre el grupo de subprocesos, vea el grupode subprocesos administrados.For more information about the thread pool, see The managed thread pool.
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. |