Question about resuming suspended thread by using event in C and W
- From: Newbiee in threading... <Newbiee in threading...@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 27 Jan 2007 07:45:00 -0800
Dear all,
I have one problem about resuming suspended thread by using event in C and
WINAPI. The snippet of code is as follows, can you help me to point out the
incorrects?
DWORD WINAPI ThreadFunction()
{
while(1)
{
ResetEvent(hGlobalWriteEvent);
WaitForSingleObject(hGlobalWriteEvent, INFINITE);
printf("Thread test is resumed.");
return 0;
}
}
void CreateEventsAndThreads(void)
{
DWORD IDThread;
hGlobalWriteEvent = CreateEvent(
NULL, // default security
attributes
TRUE, // manual-reset event
FALSE, // initial state is
nonsignaled
"WriteEvent" // object name
);
if (hGlobalWriteEvent == NULL)
{
printf("CreateEvent failed (%d)\n", GetLastError());
}
hThread = CreateThread(NULL, 0, ThreadFunction,
&hGlobalWriteEvent, // pass
event handle
CREATE_SUSPENDED,&IDThread);
if (hThread == NULL) {
printf("CreateThread failed (%d)\n", GetLastError());
}
SetEvent(hGlobalWriteEvent);
}
void main(void)
{
....
CreateEventsAndThreads();
}
.
- Follow-Ups:
- Re: Question about resuming suspended thread by using event in C and W
- From: Scott McPhillips [MVP]
- Re: Question about resuming suspended thread by using event in C and W
- Prev by Date: Re: User vs. Worker threads
- Next by Date: Re: Question about resuming suspended thread by using event in C and W
- Previous by thread: Memory mapped file pages getting cleared when memory overcommitted
- Next by thread: Re: Question about resuming suspended thread by using event in C and W
- Index(es):
Loading