ThreadPool.UnsafeRegisterWaitForSingleObject Método
Definição
Registra um representante para aguardar um WaitHandle, mas não propaga a pilha de chamadas para o thread de trabalho.Registers a delegate to wait for a WaitHandle, but does not propagate the calling stack to the worker thread.
Sobrecargas
| UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, TimeSpan, Boolean) |
Registra um delegado para aguardar um WaitHandle, especificando um valor TimeSpan para o tempo limite. Esse método não propaga a pilha de chamadas para o thread de trabalho.Registers a delegate to wait for a WaitHandle, specifying a TimeSpan value for the time-out. This method does not propagate the calling stack to the worker thread. |
| UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, Int32, Boolean) |
Registra um representante para aguardar um WaitHandle, usando um inteiro com sinal de 32 bits para o tempo limite em milissegundos.Registers a delegate to wait for a WaitHandle, using a 32-bit signed integer for the time-out in milliseconds. Esse método não propaga a pilha de chamadas para o thread de trabalho.This method does not propagate the calling stack to the worker thread. |
| UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, Int64, Boolean) |
Registra um delegado para esperar um WaitHandle, especificando um inteiro com sinal de 64 bits para o tempo limite em milissegundos.Registers a delegate to wait for a WaitHandle, specifying a 64-bit signed integer for the time-out in milliseconds. Esse método não propaga a pilha de chamadas para o thread de trabalho.This method does not propagate the calling stack to the worker thread. |
| UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, UInt32, Boolean) |
Registra um delegado para aguardar um WaitHandle, especificando um inteiro sem sinal de 32 bits para o tempo limite em milissegundos.Registers a delegate to wait for a WaitHandle, specifying a 32-bit unsigned integer for the time-out in milliseconds. Esse método não propaga a pilha de chamadas para o thread de trabalho.This method does not propagate the calling stack to the worker thread. |
UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, TimeSpan, Boolean)
Registra um delegado para aguardar um WaitHandle, especificando um valor TimeSpan para o tempo limite. Esse método não propaga a pilha de chamadas para o thread de trabalho.Registers a delegate to wait for a WaitHandle, specifying a TimeSpan value for the time-out. This method does not propagate the calling stack to the worker thread.
public:
static System::Threading::RegisteredWaitHandle ^ UnsafeRegisterWaitForSingleObject(System::Threading::WaitHandle ^ waitObject, System::Threading::WaitOrTimerCallback ^ callBack, System::Object ^ state, TimeSpan timeout, bool executeOnlyOnce);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, TimeSpan timeout, bool executeOnlyOnce);
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, TimeSpan timeout, bool executeOnlyOnce);
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, TimeSpan timeout, bool executeOnlyOnce);
[System.Security.SecurityCritical]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, TimeSpan timeout, bool executeOnlyOnce);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * TimeSpan * bool -> System.Threading.RegisteredWaitHandle
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * TimeSpan * bool -> System.Threading.RegisteredWaitHandle
[<System.Security.SecurityCritical>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * TimeSpan * bool -> System.Threading.RegisteredWaitHandle
Public Shared Function UnsafeRegisterWaitForSingleObject (waitObject As WaitHandle, callBack As WaitOrTimerCallback, state As Object, timeout As TimeSpan, executeOnlyOnce As Boolean) As RegisteredWaitHandle
Parâmetros
- waitObject
- WaitHandle
O WaitHandle a ser registrado.The WaitHandle to register. Use um WaitHandle diferente do Mutex.Use a WaitHandle other than Mutex.
- callBack
- WaitOrTimerCallback
O delegado a ser chamado quando o parâmetro waitObject é sinalizado.The delegate to call when the waitObject parameter is signaled.
- state
- Object
O objeto que é passado para o delegado.The object that is passed to the delegate.
- timeout
- TimeSpan
O tempo limite representado por um TimeSpan.The time-out represented by a TimeSpan. Se timeout for 0 (zero), a função testará o estado do objeto e será retornada imediatamente.If timeout is 0 (zero), the function tests the object's state and returns immediately. Se timeout for -1, o intervalo de tempo limite da função nunca expirará.If timeout is -1, the function's time-out interval never elapses.
- executeOnlyOnce
- Boolean
true para indicar que o thread não esperará o parâmetro waitObject depois que o delegado for chamado; false para indicar que o temporizador será reiniciado sempre que a operação de espera for concluída até que o registro da espera seja cancelado.true to indicate that the thread will no longer wait on the waitObject parameter after the delegate has been called; false to indicate that the timer is reset every time the wait operation completes until the wait is unregistered.
Retornos
O objeto RegisteredWaitHandle que pode ser usado para cancelar a operação de espera registrada.The RegisteredWaitHandle object that can be used to cancel the registered wait operation.
- Atributos
Exceções
O parâmetro timeout é menor que -1.The timeout parameter is less than -1.
O chamador não tem a permissão necessária.The caller does not have the required permission.
Comentários
Ao contrário do RegisterWaitForSingleObject método, o não UnsafeRegisterWaitForSingleObject propaga a pilha de chamadas para o thread de trabalho.Unlike the RegisterWaitForSingleObject method, UnsafeRegisterWaitForSingleObject does not propagate the calling stack to the worker thread. Isso permite que o código perca a pilha de chamadas e, portanto, eleve seus privilégios de segurança.This allows code to lose the calling stack and thereby to elevate its security privileges.
Cuidado
O uso do UnsafeRegisterWaitForSingleObject pode abrir inadvertidamente uma brecha de segurança.Using UnsafeRegisterWaitForSingleObject could inadvertently open up a security hole. A segurança de acesso ao código baseia suas verificações de permissão nas permissões de todos os chamadores na pilha.Code access security bases its permission checks on the permissions of all the callers on the stack. Quando o trabalho é enfileirado em um thread do pool de threads usando UnsafeRegisterWaitForSingleObject , a pilha do thread do pool de threads não terá o contexto dos chamadores reais.When work is queued on a thread pool thread using UnsafeRegisterWaitForSingleObject, the stack of the thread pool thread will not have the context of the actual callers. Código mal-intencionado pode ser capaz de explorar isso para evitar verificações de permissão.Malicious code might be able exploit this to avoid permission checks.
O uso de um Mutex para não waitObject fornece exclusão mútua para os retornos de chamada porque a API subjacente do Windows usa o WT_EXECUTEDEFAULT sinalizador padrão, de modo que cada retorno de chamada é expedido em um thread de pool de threads separado.Using a Mutex for waitObject does not provide mutual exclusion for the callbacks because the underlying Windows API uses the default WT_EXECUTEDEFAULT flag, so each callback is dispatched on a separate thread pool thread.
Quando você terminar de usar o RegisteredWaitHandle que é retornado por esse método, chame seu RegisteredWaitHandle.Unregister método para liberar referências para o identificador de espera.When you are finished using the RegisteredWaitHandle that is returned by this method, call its RegisteredWaitHandle.Unregister method to release references to the wait handle. É recomendável que você sempre chame o RegisteredWaitHandle.Unregister método, mesmo se especificar true for executeOnlyOnce .We recommend that you always call the RegisteredWaitHandle.Unregister method, even if you specify true for executeOnlyOnce. A coleta de lixo funciona com mais eficiência se você chamar o RegisteredWaitHandle.Unregister método em vez de, dependendo do finalizador do identificador de espera registrado.Garbage collection works more efficiently if you call the RegisteredWaitHandle.Unregister method instead of depending on the registered wait handle's finalizer.
Aplica-se a
UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, Int32, Boolean)
Registra um representante para aguardar um WaitHandle, usando um inteiro com sinal de 32 bits para o tempo limite em milissegundos.Registers a delegate to wait for a WaitHandle, using a 32-bit signed integer for the time-out in milliseconds. Esse método não propaga a pilha de chamadas para o thread de trabalho.This method does not propagate the calling stack to the worker thread.
public:
static System::Threading::RegisteredWaitHandle ^ UnsafeRegisterWaitForSingleObject(System::Threading::WaitHandle ^ waitObject, System::Threading::WaitOrTimerCallback ^ callBack, System::Object ^ state, int millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce);
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, int millisecondsTimeOutInterval, bool executeOnlyOnce);
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.Security.SecurityCritical]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, int millisecondsTimeOutInterval, bool executeOnlyOnce);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * int * bool -> System.Threading.RegisteredWaitHandle
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * int * bool -> System.Threading.RegisteredWaitHandle
[<System.Security.SecurityCritical>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * int * bool -> System.Threading.RegisteredWaitHandle
Public Shared Function UnsafeRegisterWaitForSingleObject (waitObject As WaitHandle, callBack As WaitOrTimerCallback, state As Object, millisecondsTimeOutInterval As Integer, executeOnlyOnce As Boolean) As RegisteredWaitHandle
Parâmetros
- waitObject
- WaitHandle
O WaitHandle a ser registrado.The WaitHandle to register. Use um WaitHandle diferente do Mutex.Use a WaitHandle other than Mutex.
- callBack
- WaitOrTimerCallback
O delegado a ser chamado quando o parâmetro waitObject é sinalizado.The delegate to call when the waitObject parameter is signaled.
- state
- Object
O objeto que é passado para o delegado.The object that is passed to the delegate.
- millisecondsTimeOutInterval
- Int32
O tempo limite em milissegundos.The time-out in milliseconds. Se o parâmetro millisecondsTimeOutInterval for 0 (zero), a função testará o estado do objeto e será imediatamente retornada.If the millisecondsTimeOutInterval parameter is 0 (zero), the function tests the object's state and returns immediately. Se millisecondsTimeOutInterval for -1, o intervalo de tempo limite da função nunca expirará.If millisecondsTimeOutInterval is -1, the function's time-out interval never elapses.
- executeOnlyOnce
- Boolean
true para indicar que o thread não esperará o parâmetro waitObject depois que o delegado for chamado; false para indicar que o temporizador será reiniciado sempre que a operação de espera for concluída até que o registro da espera seja cancelado.true to indicate that the thread will no longer wait on the waitObject parameter after the delegate has been called; false to indicate that the timer is reset every time the wait operation completes until the wait is unregistered.
Retornos
O objeto RegisteredWaitHandle que pode ser usado para cancelar a operação de espera registrada.The RegisteredWaitHandle object that can be used to cancel the registered wait operation.
- Atributos
Exceções
O parâmetro millisecondsTimeOutInterval é menor que -1.The millisecondsTimeOutInterval parameter is less than -1.
O chamador não tem a permissão necessária.The caller does not have the required permission.
Comentários
Ao contrário do RegisterWaitForSingleObject método, o não UnsafeRegisterWaitForSingleObject propaga a pilha de chamadas para o thread de trabalho.Unlike the RegisterWaitForSingleObject method, UnsafeRegisterWaitForSingleObject does not propagate the calling stack to the worker thread. Isso permite que o código perca a pilha de chamadas e, portanto, eleve seus privilégios de segurança.This allows code to lose the calling stack and thereby to elevate its security privileges.
Cuidado
O uso do UnsafeRegisterWaitForSingleObject pode abrir inadvertidamente uma brecha de segurança.Using UnsafeRegisterWaitForSingleObject could inadvertently open up a security hole. A segurança de acesso ao código baseia suas verificações de permissão nas permissões de todos os chamadores na pilha.Code access security bases its permission checks on the permissions of all the callers on the stack. Quando o trabalho é enfileirado em um thread do pool de threads usando UnsafeRegisterWaitForSingleObject , a pilha do thread do pool de threads não terá o contexto dos chamadores reais.When work is queued on a thread pool thread using UnsafeRegisterWaitForSingleObject, the stack of the thread pool thread will not have the context of the actual callers. Código mal-intencionado pode ser capaz de explorar isso para evitar verificações de permissão.Malicious code might be able exploit this to avoid permission checks.
O uso de um Mutex para não waitObject fornece exclusão mútua para os retornos de chamada porque a API subjacente do Windows usa o WT_EXECUTEDEFAULT sinalizador padrão, de modo que cada retorno de chamada é expedido em um thread de pool de threads separado.Using a Mutex for waitObject does not provide mutual exclusion for the callbacks because the underlying Windows API uses the default WT_EXECUTEDEFAULT flag, so each callback is dispatched on a separate thread pool thread.
Quando você terminar de usar o RegisteredWaitHandle que é retornado por esse método, chame seu RegisteredWaitHandle.Unregister método para liberar referências para o identificador de espera.When you are finished using the RegisteredWaitHandle that is returned by this method, call its RegisteredWaitHandle.Unregister method to release references to the wait handle. É recomendável que você sempre chame o RegisteredWaitHandle.Unregister método, mesmo se especificar true for executeOnlyOnce .We recommend that you always call the RegisteredWaitHandle.Unregister method, even if you specify true for executeOnlyOnce. A coleta de lixo funciona com mais eficiência se você chamar o RegisteredWaitHandle.Unregister método em vez de, dependendo do finalizador do identificador de espera registrado.Garbage collection works more efficiently if you call the RegisteredWaitHandle.Unregister method instead of depending on the registered wait handle's finalizer.
Aplica-se a
UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, Int64, Boolean)
Registra um delegado para esperar um WaitHandle, especificando um inteiro com sinal de 64 bits para o tempo limite em milissegundos.Registers a delegate to wait for a WaitHandle, specifying a 64-bit signed integer for the time-out in milliseconds. Esse método não propaga a pilha de chamadas para o thread de trabalho.This method does not propagate the calling stack to the worker thread.
public:
static System::Threading::RegisteredWaitHandle ^ UnsafeRegisterWaitForSingleObject(System::Threading::WaitHandle ^ waitObject, System::Threading::WaitOrTimerCallback ^ callBack, System::Object ^ state, long millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce);
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce);
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.Security.SecurityCritical]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * int64 * bool -> System.Threading.RegisteredWaitHandle
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * int64 * bool -> System.Threading.RegisteredWaitHandle
[<System.Security.SecurityCritical>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * int64 * bool -> System.Threading.RegisteredWaitHandle
Public Shared Function UnsafeRegisterWaitForSingleObject (waitObject As WaitHandle, callBack As WaitOrTimerCallback, state As Object, millisecondsTimeOutInterval As Long, executeOnlyOnce As Boolean) As RegisteredWaitHandle
Parâmetros
- waitObject
- WaitHandle
O WaitHandle a ser registrado.The WaitHandle to register. Use um WaitHandle diferente do Mutex.Use a WaitHandle other than Mutex.
- callBack
- WaitOrTimerCallback
O delegado a ser chamado quando o parâmetro waitObject é sinalizado.The delegate to call when the waitObject parameter is signaled.
- state
- Object
O objeto que é passado para o delegado.The object that is passed to the delegate.
- millisecondsTimeOutInterval
- Int64
O tempo limite em milissegundos.The time-out in milliseconds. Se o parâmetro millisecondsTimeOutInterval for 0 (zero), a função testará o estado do objeto e será imediatamente retornada.If the millisecondsTimeOutInterval parameter is 0 (zero), the function tests the object's state and returns immediately. Se millisecondsTimeOutInterval for -1, o intervalo de tempo limite da função nunca expirará.If millisecondsTimeOutInterval is -1, the function's time-out interval never elapses.
- executeOnlyOnce
- Boolean
true para indicar que o thread não esperará o parâmetro waitObject depois que o delegado for chamado; false para indicar que o temporizador será reiniciado sempre que a operação de espera for concluída até que o registro da espera seja cancelado.true to indicate that the thread will no longer wait on the waitObject parameter after the delegate has been called; false to indicate that the timer is reset every time the wait operation completes until the wait is unregistered.
Retornos
O objeto RegisteredWaitHandle que pode ser usado para cancelar a operação de espera registrada.The RegisteredWaitHandle object that can be used to cancel the registered wait operation.
- Atributos
Exceções
O parâmetro millisecondsTimeOutInterval é menor que -1.The millisecondsTimeOutInterval parameter is less than -1.
O chamador não tem a permissão necessária.The caller does not have the required permission.
Comentários
Ao contrário do RegisterWaitForSingleObject método, o não UnsafeRegisterWaitForSingleObject propaga a pilha de chamadas para o thread de trabalho.Unlike the RegisterWaitForSingleObject method, UnsafeRegisterWaitForSingleObject does not propagate the calling stack to the worker thread. Isso permite que o código perca a pilha de chamadas e, portanto, eleve seus privilégios de segurança.This allows code to lose the calling stack and thereby to elevate its security privileges.
Cuidado
O uso do UnsafeRegisterWaitForSingleObject pode abrir inadvertidamente uma brecha de segurança.Using UnsafeRegisterWaitForSingleObject could inadvertently open up a security hole. A segurança de acesso ao código baseia suas verificações de permissão nas permissões de todos os chamadores na pilha.Code access security bases its permission checks on the permissions of all the callers on the stack. Quando o trabalho é enfileirado em um thread do pool de threads usando UnsafeRegisterWaitForSingleObject , a pilha do thread do pool de threads não terá o contexto dos chamadores reais.When work is queued on a thread pool thread using UnsafeRegisterWaitForSingleObject, the stack of the thread pool thread will not have the context of the actual callers. Código mal-intencionado pode ser capaz de explorar isso para evitar verificações de permissão.Malicious code might be able exploit this to avoid permission checks.
O uso de um Mutex para não waitObject fornece exclusão mútua para os retornos de chamada porque a API subjacente do Windows usa o WT_EXECUTEDEFAULT sinalizador padrão, de modo que cada retorno de chamada é expedido em um thread de pool de threads separado.Using a Mutex for waitObject does not provide mutual exclusion for the callbacks because the underlying Windows API uses the default WT_EXECUTEDEFAULT flag, so each callback is dispatched on a separate thread pool thread.
Quando você terminar de usar o RegisteredWaitHandle que é retornado por esse método, chame seu RegisteredWaitHandle.Unregister método para liberar referências para o identificador de espera.When you are finished using the RegisteredWaitHandle that is returned by this method, call its RegisteredWaitHandle.Unregister method to release references to the wait handle. É recomendável que você sempre chame o RegisteredWaitHandle.Unregister método, mesmo se especificar true for executeOnlyOnce .We recommend that you always call the RegisteredWaitHandle.Unregister method, even if you specify true for executeOnlyOnce. A coleta de lixo funciona com mais eficiência se você chamar o RegisteredWaitHandle.Unregister método em vez de, dependendo do finalizador do identificador de espera registrado.Garbage collection works more efficiently if you call the RegisteredWaitHandle.Unregister method instead of depending on the registered wait handle's finalizer.
Aplica-se a
UnsafeRegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, UInt32, Boolean)
Importante
Esta API não está em conformidade com CLS.
Registra um delegado para aguardar um WaitHandle, especificando um inteiro sem sinal de 32 bits para o tempo limite em milissegundos.Registers a delegate to wait for a WaitHandle, specifying a 32-bit unsigned integer for the time-out in milliseconds. Esse método não propaga a pilha de chamadas para o thread de trabalho.This method does not propagate the calling stack to the worker thread.
public:
static System::Threading::RegisteredWaitHandle ^ UnsafeRegisterWaitForSingleObject(System::Threading::WaitHandle ^ waitObject, System::Threading::WaitOrTimerCallback ^ callBack, System::Object ^ state, System::UInt32 millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.CLSCompliant(false)]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.CLSCompliant(false)]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject (System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce);
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * uint32 * bool -> System.Threading.RegisteredWaitHandle
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * uint32 * bool -> System.Threading.RegisteredWaitHandle
[<System.CLSCompliant(false)>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * uint32 * bool -> System.Threading.RegisteredWaitHandle
[<System.CLSCompliant(false)>]
[<System.Security.SecurityCritical>]
static member UnsafeRegisterWaitForSingleObject : System.Threading.WaitHandle * System.Threading.WaitOrTimerCallback * obj * uint32 * bool -> System.Threading.RegisteredWaitHandle
Public Shared Function UnsafeRegisterWaitForSingleObject (waitObject As WaitHandle, callBack As WaitOrTimerCallback, state As Object, millisecondsTimeOutInterval As UInteger, executeOnlyOnce As Boolean) As RegisteredWaitHandle
Parâmetros
- waitObject
- WaitHandle
O WaitHandle a ser registrado.The WaitHandle to register. Use um WaitHandle diferente do Mutex.Use a WaitHandle other than Mutex.
- callBack
- WaitOrTimerCallback
O delegado a ser chamado quando o parâmetro waitObject é sinalizado.The delegate to call when the waitObject parameter is signaled.
- state
- Object
O objeto que é passado para o delegado.The object that is passed to the delegate.
- millisecondsTimeOutInterval
- UInt32
O tempo limite em milissegundos.The time-out in milliseconds. Se o parâmetro millisecondsTimeOutInterval for 0 (zero), a função testará o estado do objeto e será imediatamente retornada.If the millisecondsTimeOutInterval parameter is 0 (zero), the function tests the object's state and returns immediately. Se millisecondsTimeOutInterval for -1, o intervalo de tempo limite da função nunca expirará.If millisecondsTimeOutInterval is -1, the function's time-out interval never elapses.
- executeOnlyOnce
- Boolean
true para indicar que o thread não esperará o parâmetro waitObject depois que o delegado for chamado; false para indicar que o temporizador será reiniciado sempre que a operação de espera for concluída até que o registro da espera seja cancelado.true to indicate that the thread will no longer wait on the waitObject parameter after the delegate has been called; false to indicate that the timer is reset every time the wait operation completes until the wait is unregistered.
Retornos
O objeto RegisteredWaitHandle que pode ser usado para cancelar a operação de espera registrada.The RegisteredWaitHandle object that can be used to cancel the registered wait operation.
- Atributos
Exceções
O chamador não tem a permissão necessária.The caller does not have the required permission.
Comentários
Ao contrário do RegisterWaitForSingleObject método, o não UnsafeRegisterWaitForSingleObject propaga a pilha de chamadas para o thread de trabalho.Unlike the RegisterWaitForSingleObject method, UnsafeRegisterWaitForSingleObject does not propagate the calling stack to the worker thread. Isso permite que o código perca a pilha de chamadas e, portanto, eleve seus privilégios de segurança.This allows code to lose the calling stack and thereby to elevate its security privileges.
Cuidado
O uso do UnsafeRegisterWaitForSingleObject pode abrir inadvertidamente uma brecha de segurança.Using UnsafeRegisterWaitForSingleObject could inadvertently open up a security hole. A segurança de acesso ao código baseia suas verificações de permissão nas permissões de todos os chamadores na pilha.Code access security bases its permission checks on the permissions of all the callers on the stack. Quando o trabalho é enfileirado em um thread do pool de threads usando UnsafeRegisterWaitForSingleObject , a pilha do thread do pool de threads não terá o contexto dos chamadores reais.When work is queued on a thread pool thread using UnsafeRegisterWaitForSingleObject, the stack of the thread pool thread will not have the context of the actual callers. Código mal-intencionado pode ser capaz de explorar isso para evitar verificações de permissão.Malicious code might be able exploit this to avoid permission checks.
O uso de um Mutex para não waitObject fornece exclusão mútua para os retornos de chamada porque a API subjacente do Windows usa o WT_EXECUTEDEFAULT sinalizador padrão, de modo que cada retorno de chamada é expedido em um thread de pool de threads separado.Using a Mutex for waitObject does not provide mutual exclusion for the callbacks because the underlying Windows API uses the default WT_EXECUTEDEFAULT flag, so each callback is dispatched on a separate thread pool thread.
Quando você terminar de usar o RegisteredWaitHandle que é retornado por esse método, chame seu RegisteredWaitHandle.Unregister método para liberar referências para o identificador de espera.When you are finished using the RegisteredWaitHandle that is returned by this method, call its RegisteredWaitHandle.Unregister method to release references to the wait handle. É recomendável que você sempre chame o RegisteredWaitHandle.Unregister método, mesmo se especificar true for executeOnlyOnce .We recommend that you always call the RegisteredWaitHandle.Unregister method, even if you specify true for executeOnlyOnce. A coleta de lixo funciona com mais eficiência se você chamar o RegisteredWaitHandle.Unregister método em vez de, dependendo do finalizador do identificador de espera registrado.Garbage collection works more efficiently if you call the RegisteredWaitHandle.Unregister method instead of depending on the registered wait handle's finalizer.