Reprinted: http://www.vchelp.net/ The original author's name fang (fangguicheng@21cn.com) Text asynchronous IO, APC, IO completed port, thread pool and high performance server 2 APC Alertable IO (Alarm IO) provided More efficient asynchronous notification form. ReadFileEx / WriteFileEx provides a callback function (APC process) while issuing IO requests. When the IO request is completed, the callback function will be executed once the thread enters the alarm state. The following five functions enable the thread to enter the alarm status: The Sleepex WaitForsingleObjectEx WaitFormultiPleObjectsex SignalObjectandWait MsgwaitFormultiPleObjectSEX thread When the necroscope will check the thread's APC queue. If there is an APC in the queue, it will be executed in the FIFO mode. If the queue is empty, the thread will hang a wait object. At some point in the future, once the APC enters the queue, the thread will be awakened to execute the APC, while waiting for the function to return to WAIT_IO_COMPLETION. QueueUSeraPC can be used to deliver APC, as long as the target thread is on the alarm state, the APC can be executed. The main disadvantage of using the alarm IO is that the thread that issues the IO request must also be a thread of the processing result. If there is an unfinished IO request when a thread exits, then the application will always lose IO to complete the notification. However, we will see that the IO completion port does not have this limit. The following code demonstrates the usage of QueueUseraPC.