Click here to Skip to main content
15,915,513 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CreateProcess puzzle Pin
Antony M Kancidrowski30-Sep-04 12:32
Antony M Kancidrowski30-Sep-04 12:32 
GeneralMedia Player Mini-Mode Pin
Dave Moran28-Sep-04 1:26
Dave Moran28-Sep-04 1:26 
GeneralRe: Media Player Mini-Mode Pin
Antony M Kancidrowski28-Sep-04 2:04
Antony M Kancidrowski28-Sep-04 2:04 
GeneralRe: Media Player Mini-Mode Pin
Dave Moran28-Sep-04 13:50
Dave Moran28-Sep-04 13:50 
GeneralRe: Media Player Mini-Mode Pin
Antony M Kancidrowski29-Sep-04 0:38
Antony M Kancidrowski29-Sep-04 0:38 
QuestionHow Can I making database project? Pin
Majid Shahpouri28-Sep-04 1:03
Majid Shahpouri28-Sep-04 1:03 
AnswerRe: How Can I making database project? Pin
GermanGeorge28-Sep-04 4:07
GermanGeorge28-Sep-04 4:07 
Generalwhile loop in threads Pin
ledallam28-Sep-04 0:40
ledallam28-Sep-04 0:40 
Hello,

In my project, I have to check if a particular condition is satisfied and take some action accordingly. Hence I have started a thread which continously checks for the condition as shown below:

UINT ThreadProc(LPVOID lp)
{
while(TRUE)
{
DWORD dwWaitResult = WaitForSingleObject(MonitorEvent,INFINITE);
switch (dwWaitResult)
{
case WAIT_OBJECT_0:
//do the required action and ...reset event
ResetEvent(MonitorEvent);
break;
}

}
MonitorEvent will be set in the part of the code where the required condition is met. Once the the event is fired, ThreadProc acts and does the required task and again has to wait till the event is fired again. This has to continue till application exists.

The result of the above code is that CPU time is getting consumed 100%.
Can anyone please suggest a better solution?
Thanks in anticipation of information.

madhavi.
GeneralRe: while loop in threads Pin
Manfred Staiger28-Sep-04 1:06
Manfred Staiger28-Sep-04 1:06 
GeneralRe: while loop in threads Pin
Aamir Butt28-Sep-04 1:25
Aamir Butt28-Sep-04 1:25 
GeneralRe: while loop in threads Pin
Blake Miller28-Sep-04 4:30
Blake Miller28-Sep-04 4:30 
GeneralRe: while loop in threads Pin
ledallam28-Sep-04 18:10
ledallam28-Sep-04 18:10 
GeneralRe: while loop in threads Pin
David Crow28-Sep-04 4:05
David Crow28-Sep-04 4:05 
GeneralRe: while loop in threads Pin
Andrzej Markowski28-Sep-04 8:10
Andrzej Markowski28-Sep-04 8:10 
GeneralRe: while loop in threads Pin
ledallam28-Sep-04 18:11
ledallam28-Sep-04 18:11 
GeneralRe: while loop in threads Pin
Andrzej Markowski28-Sep-04 19:38
Andrzej Markowski28-Sep-04 19:38 
GeneralRe: while loop in threads Pin
ledallam28-Sep-04 19:48
ledallam28-Sep-04 19:48 
GeneralRe: while loop in threads Pin
Andrzej Markowski28-Sep-04 20:09
Andrzej Markowski28-Sep-04 20:09 
GeneralRe: while loop in threads Pin
ledallam28-Sep-04 20:30
ledallam28-Sep-04 20:30 
GeneralRe: while loop in threads Pin
Andrzej Markowski28-Sep-04 20:50
Andrzej Markowski28-Sep-04 20:50 
GeneralRe: while loop in threads Pin
ledallam28-Sep-04 21:17
ledallam28-Sep-04 21:17 
GeneralRe: while loop in threads Pin
Andrzej Markowski28-Sep-04 21:32
Andrzej Markowski28-Sep-04 21:32 
GeneralRe: while loop in threads Pin
ledallam28-Sep-04 21:39
ledallam28-Sep-04 21:39 
GeneralRe: while loop in threads Pin
Blake Miller29-Sep-04 4:22
Blake Miller29-Sep-04 4:22 
GeneralCalling vb .net dll in a C++ console app Pin
Tumisang28-Sep-04 0:26
Tumisang28-Sep-04 0:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.