NTSTATUS KiSwitchToThread( IN PKTHREAD NextThread, IN ULONG WaitReason, IN ULONG WaitMode, IN PKEVENT WaitObject ); Routine Description: This function performs an optimal switch to the specified target thread if possible. No timeout is associated with the wait, thus the issuing thread will wait until the wait event is signaled or an APC is deliverd. N.B. This routine is called with the dispatcher database locked. N.B. The wait IRQL is assumed to be set for the current thread and the wait status is assumed to be set for the target thread. N.B. It is assumed that if a queue is associated with the target thread, then the concurrency count has been incremented. N.B. Control is returned from this function with the dispatcher database unlocked. Arguments: NextThread - Supplies a pointer to a dispatcher object of type thread. WaitReason - Supplies the reason for the wait operation. WaitMode - Supplies the processor wait mode. WaitObject - Supplies a pointer to a dispatcher object of type event or semaphore. Return Value: The wait completion status. A value of STATUS_SUCCESS is returned if the specified object satisfied the wait. A value of STATUS_USER_APC is returned if the wait was aborted to deliver a user APC to the current thread.