Click here to Skip to main content
15,908,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Overflowing the Windows’s message Queue Pin
Roger Stoltz8-Jan-09 12:05
Roger Stoltz8-Jan-09 12:05 
GeneralRe: Overflowing the Windows’s message Queue Pin
Code-o-mat8-Jan-09 21:38
Code-o-mat8-Jan-09 21:38 
GeneralRe: Overflowing the Windows’s message Queue Pin
BobInNJ9-Jan-09 8:02
BobInNJ9-Jan-09 8:02 
AnswerRe: Overflowing the Windows’s message Queue Pin
David Crow8-Jan-09 9:08
David Crow8-Jan-09 9:08 
GeneralRe: Overflowing the Windows’s message Queue Pin
BobInNJ8-Jan-09 10:03
BobInNJ8-Jan-09 10:03 
GeneralRe: Overflowing the Windows’s message Queue Pin
David Crow8-Jan-09 10:13
David Crow8-Jan-09 10:13 
GeneralRe: Overflowing the Windows’s message Queue Pin
BobInNJ8-Jan-09 11:12
BobInNJ8-Jan-09 11:12 
QuestionRe: Overflowing the Windows’s message Queue Pin
Roger Stoltz8-Jan-09 12:11
Roger Stoltz8-Jan-09 12:11 
What are you trying to do? Confused | :confused:

Have you really thought about how you've designed the application and what the requirements are, especially the timing requirements?
You've created two worker threads that do some kind of simulation and you want to alert the UI thread in order to display the result of the simulation, I guess.

When it comes to secondary threads you should never use ::SendMessage() because you may deadlock your application if the main thread doesn't pump messages. Use ::PostMessage() instead. David has already advised you regarding this matter.

Now to what I believe is the real problem if I may read a little between the lines of your posts....
Worker threads are mostly used when you have some kind of computing to do that takes a lot of time when you don't want your user interface to freeze up. When the computation is done you alert the UI thread by posting a user defined message.
Since you believe that you choke the UI thread with messages, I guess the simulation is done rather fast and thus would not need a secondary thread. Either that or your UI thread doesn't process messages the way it's supposed to.
It sounds like your simulation takes a lot less time than displaying the results of it which means that you choke the UI thread; for every message it processes it will get more than one in the queue and it's all downhill from there. Putting calls to ::Sleep() does not in any way solve the problem, it simply disguises it.

From my point of view this issue is more about design than how big the message queue is, or can be.
To be able to give a more accurate suggestion you have to provide more information about what you're trying to do; what is a simulation, how long does it take to perform a simulation, what kind of data is displayed and so on.
But based on the information you've given so far I would suggest the following:
Create a queue of your own that holds simulation results, e.g. std::queue. Protect the queue with a critical section since it will be read from the UI thread and written to from the worker threads. Let the UI thread periodically poll the queue and display the results.
Now this may be a solution that doesn't really meet the requirements of your application, but since you haven't mentioned them this can serve as a starting point.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


GeneralRe: Overflowing the Windows’s message Queue Pin
Luc Pattyn8-Jan-09 13:21
sitebuilderLuc Pattyn8-Jan-09 13:21 
GeneralRe: Overflowing the Windows’s message Queue Pin
Roger Stoltz8-Jan-09 22:30
Roger Stoltz8-Jan-09 22:30 
AnswerRe: Overflowing the Windows’s message Queue Pin
BobInNJ8-Jan-09 14:24
BobInNJ8-Jan-09 14:24 
GeneralRe: Overflowing the Windows’s message Queue Pin
Cedric Moonen8-Jan-09 20:27
Cedric Moonen8-Jan-09 20:27 
GeneralRe: Overflowing the Windows’s message Queue Pin
Roger Stoltz8-Jan-09 22:54
Roger Stoltz8-Jan-09 22:54 
GeneralRe: Overflowing the Windows’s message Queue Pin
Cedric Moonen8-Jan-09 22:57
Cedric Moonen8-Jan-09 22:57 
GeneralRe: Overflowing the Windows’s message Queue Pin
Roger Stoltz8-Jan-09 23:05
Roger Stoltz8-Jan-09 23:05 
GeneralRe: Overflowing the Windows’s message Queue Pin
Luc Pattyn9-Jan-09 1:31
sitebuilderLuc Pattyn9-Jan-09 1:31 
GeneralRe: Overflowing the Windows’s message Queue Pin
Roger Stoltz9-Jan-09 1:44
Roger Stoltz9-Jan-09 1:44 
GeneralRe: Overflowing the Windows’s message Queue Pin
BobInNJ9-Jan-09 6:31
BobInNJ9-Jan-09 6:31 
GeneralRe: Overflowing the Windows’s message Queue Pin
Roger Stoltz8-Jan-09 23:11
Roger Stoltz8-Jan-09 23:11 
AnswerRe: Overflowing the Windows’s message Queue Pin
Rolf Kristensen10-Jan-09 2:02
Rolf Kristensen10-Jan-09 2:02 
GeneralRe: Overflowing the Windows’s message Queue Pin
BobInNJ10-Jan-09 8:47
BobInNJ10-Jan-09 8:47 
GeneralRe: Overflowing the Windows’s message Queue Pin
Rolf Kristensen11-Jan-09 1:15
Rolf Kristensen11-Jan-09 1:15 
QuestionEdit control with HTML link Pin
sabapathy_808-Jan-09 5:00
sabapathy_808-Jan-09 5:00 
AnswerRe: Edit control with HTML link Pin
Iain Clarke, Warrior Programmer8-Jan-09 5:04
Iain Clarke, Warrior Programmer8-Jan-09 5:04 
GeneralRe: Edit control with HTML link Pin
sabapathy_808-Jan-09 5:14
sabapathy_808-Jan-09 5:14 

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.