#define _WIN32_WINNT 0x0500 #include #include DWORD __stdcall thread_function( void* Param ) { int i = 0; while( i++ < 10 ) printf( "Thread...\n" ); return 0; } void __stdcall apc_function( DWORD dwParam ) { int i = 0; while( i++ < 60 ) printf( "APC...\n" ); } int main( int argc, char** argv ) { HANDLE hThread = NULL; hThread = CreateThread( NULL, 0, thread_function, NULL, CREATE_SUSPENDED, NULL ); if( !hThread ) printf( "Could not create thread!\n" ); if( !QueueUserAPC( apc_function, hThread, 0 ) ) printf( "Could not create APC!\n" ); ResumeThread( hThread ); WaitForSingleObject( hThread, INFINITE ); CloseHandle( hThread ); return 0; }