I started reading about APC recently and started writing examples.
on the first example i came into, the program crashes when the APC is scheduled
maybe one of you can explain the reason?
the code is
Hello
Bye
and then it crashes
any ideas?
Thanks
on the first example i came into, the program crashes when the APC is scheduled
maybe one of you can explain the reason?
the code is
Code: Select all
The output is:#define _WIN32_WINNT 0x0400
#include <Windows.h>
#include <stdio.h>
void SayHello() {
while( TRUE ) {
printf("Hello\n");
SleepEx( 1000, TRUE );
}
}
void CALLBACK SayGoodbye() {
printf("Bye\n");
}
int main(int argc, char *argv[]) {
HANDLE hThread;
hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)&SayHello, NULL, 0, NULL );
Sleep( 5000 );
QueueUserAPC( (PAPCFUNC)SayGoodbye, hThread, 0 );
Sleep( 1000 );
return 0;
}
Hello
Bye
and then it crashes
any ideas?
Thanks