Click here to Skip to main content
16,005,697 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: error c2511: unresolved external symbol in EVC++ Pin
Rajesh R Subramanian16-Jan-07 19:11
professionalRajesh R Subramanian16-Jan-07 19:11 
GeneralRe: error c2511: unresolved external symbol in EVC++ Pin
harshadha16-Jan-07 20:03
harshadha16-Jan-07 20:03 
QuestionReceive a message in worker thread Pin
Ajay L D16-Jan-07 17:47
Ajay L D16-Jan-07 17:47 
AnswerRe: Receive a message in worker thread Pin
Neville Franks16-Jan-07 18:24
Neville Franks16-Jan-07 18:24 
AnswerRe: Receive a message in worker thread Pin
Mark Salsbery16-Jan-07 18:48
Mark Salsbery16-Jan-07 18:48 
QuestionRe: Receive a message in worker thread [modified] Pin
Roger Stoltz16-Jan-07 20:38
Roger Stoltz16-Jan-07 20:38 
AnswerRe: Receive a message in worker thread Pin
Steve S16-Jan-07 21:32
Steve S16-Jan-07 21:32 
GeneralRe: Receive a message in worker thread Pin
Roger Stoltz16-Jan-07 21:56
Roger Stoltz16-Jan-07 21:56 
Steve S wrote:
Having a worker thread polling is not generally a good idea, but waiting on an event, on the other hand...


What I meant, which unfortunately was not very clear, was a special case for a worker thread that doesn't wait for anything. It has a specific task that consumes 100% of the thread time slices and the thread would terminate when the task has completed. If you need to cancel the task prematurely I think it would be suitable by polling (or rather checking) a flag. But of course, there's always the possibility for calling ::WaitForSingleObject() with the timeout value set to zero, but that feels like overkill.

I was hoping for the OP to post again allowing me to pick up the "thread". Wink | ;)


Steve S wrote:
I inherited some code that polled, and because the person writing it was using a sleep inside the loop, they thought it would be OK. The thread was eating around 30% of the available CPU time while it waited, until I changed it to use an event, whereupon it "magically" dropped.


::Sleep() is one of the features that are so heavily abused and misused that I lack the words for it.
Every time anyone is trying to fix a threading issue by the use of ::Sleep() the code is almost certain to be wrong and even the design could be assumed to be erroneous.

If you haven't read Joe Newcomer's article about multithreading, which I included a link to in my previous post, have a go on it. It summarizes the common pitfalls quite clearly.
But, if I'm not mistaking, I think you already know...

Have a good one Steve
--
Roger


"It's supposed to be hard, otherwise anybody could do it!" - selfquote

QuestionI hope to get a message when CMyListCtrl's styles been changed! Pin
eat_union16-Jan-07 16:11
eat_union16-Jan-07 16:11 
AnswerRe: I hope to get a message when CMyListCtrl's styles been changed! Pin
Nibu babu thomas16-Jan-07 16:18
Nibu babu thomas16-Jan-07 16:18 
GeneralRe: I hope to get a message when CMyListCtrl's styles been changed! Pin
eat_union21-Jan-07 15:51
eat_union21-Jan-07 15:51 
QuestionClass Wizard Pin
Merlin Vilhauer16-Jan-07 15:13
Merlin Vilhauer16-Jan-07 15:13 
AnswerRe: Class Wizard Pin
Christian Graus16-Jan-07 15:36
protectorChristian Graus16-Jan-07 15:36 
AnswerRe: Class Wizard Pin
prasad_som16-Jan-07 17:24
prasad_som16-Jan-07 17:24 
QuestionClient / Server Pin
Dosin16-Jan-07 14:21
Dosin16-Jan-07 14:21 
AnswerRe: Client / Server Pin
Mark Salsbery16-Jan-07 14:49
Mark Salsbery16-Jan-07 14:49 
GeneralRe: Client / Server Pin
Dosin16-Jan-07 16:14
Dosin16-Jan-07 16:14 
QuestionRe: Client / Server Pin
Rajesh R Subramanian16-Jan-07 19:28
professionalRajesh R Subramanian16-Jan-07 19:28 
Questiontype casting float to int/short Pin
acerunner31616-Jan-07 13:07
acerunner31616-Jan-07 13:07 
AnswerRe: type casting float to int/short Pin
Christian Graus16-Jan-07 13:17
protectorChristian Graus16-Jan-07 13:17 
GeneralRe: type casting float to int/short [modified] Pin
acerunner31616-Jan-07 13:29
acerunner31616-Jan-07 13:29 
GeneralRe: type casting float to int/short Pin
Christian Graus16-Jan-07 13:40
protectorChristian Graus16-Jan-07 13:40 
GeneralRe: type casting float to int/short Pin
acerunner31616-Jan-07 13:45
acerunner31616-Jan-07 13:45 
GeneralRe: type casting float to int/short Pin
Christian Graus16-Jan-07 15:37
protectorChristian Graus16-Jan-07 15:37 
AnswerRe: type casting float to int/short Pin
Rick York16-Jan-07 13:38
mveRick York16-Jan-07 13:38 

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.