Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CRectTracker Pin
Eugen Podsypalnikov13-Apr-10 3:00
Eugen Podsypalnikov13-Apr-10 3:00 
QuestionMFC Thread queue size Pin
ajmalsiddiqi12-Apr-10 23:42
ajmalsiddiqi12-Apr-10 23:42 
QuestionRe: MFC Thread queue size Pin
David Crow13-Apr-10 2:52
David Crow13-Apr-10 2:52 
AnswerRe: MFC Thread queue size Pin
ajmalsiddiqi13-Apr-10 7:14
ajmalsiddiqi13-Apr-10 7:14 
GeneralRe: MFC Thread queue size Pin
David Crow13-Apr-10 7:32
David Crow13-Apr-10 7:32 
AnswerRe: MFC Thread queue size Pin
Stephen Hewitt13-Apr-10 13:57
Stephen Hewitt13-Apr-10 13:57 
GeneralRe: MFC Thread queue size Pin
ajmalsiddiqi13-Apr-10 21:30
ajmalsiddiqi13-Apr-10 21:30 
GeneralRe: MFC Thread queue size Pin
Stephen Hewitt14-Apr-10 1:18
Stephen Hewitt14-Apr-10 1:18 
There are a number of issues here.
 
The first problem you may encounter is related to the posting of thread messages. Does the main thread have any UI? Messages boxes, dialogs, anything like that? If so you may encounter the problem described here[^]. The solution (posting the messages to a hidden window instead) is also described.
 
The next problem is that the main thread will sometimes throw away messages:
// code snap shot
Controller::Run()
{
	While(1)
	{
		while(PeekMessage(pmsg, NULL, 0, 0, PM_NOREMOVE)) // -(1)
		{
			switch(pmsg ->message)
			{
			case MSG_RE_START:
			// log here pending messages in queue
			//do some functionality
			case MSG_RE_StOP:
			// log here pending messages in queue
			//do some functionality
			}
		}

		PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE); // -(2)
	}
}

If there are no messages in the queue at point (1) but there is at point (2) the message is simply discarded.

Another issue is that the main thread is constantly spinning in a busy loop doing nothing, degrading system performance.

Also you simply discard all messages, even ones that don't belong to you. You should dispatch them.

Also, even if your code was even close to working (which it's not) how do you know all the messages in the queue are yours?
Steve

GeneralRe: MFC Thread queue size Pin
ajmalsiddiqi14-Apr-10 2:10
ajmalsiddiqi14-Apr-10 2:10 
GeneralRe: MFC Thread queue size Pin
Stephen Hewitt14-Apr-10 2:48
Stephen Hewitt14-Apr-10 2:48 
GeneralRe: MFC Thread queue size Pin
ajmalsiddiqi14-Apr-10 3:35
ajmalsiddiqi14-Apr-10 3:35 
QuestionCustom dropdown for CComboBox [modified] Pin
SpaceMonkey197012-Apr-10 21:25
SpaceMonkey197012-Apr-10 21:25 
AnswerRe: Custom dropdown for CComboBox Pin
Iain Clarke, Warrior Programmer12-Apr-10 22:57
Iain Clarke, Warrior Programmer12-Apr-10 22:57 
GeneralRe: Custom dropdown for CComboBox Pin
SpaceMonkey197013-Apr-10 0:47
SpaceMonkey197013-Apr-10 0:47 
GeneralRe: Custom dropdown for CComboBox Pin
Iain Clarke, Warrior Programmer13-Apr-10 0:56
Iain Clarke, Warrior Programmer13-Apr-10 0:56 
AnswerRe: Custom dropdown for CComboBox Pin
Code-o-mat13-Apr-10 6:18
Code-o-mat13-Apr-10 6:18 
GeneralRe: Custom dropdown for CComboBox Pin
SpaceMonkey197013-Apr-10 8:49
SpaceMonkey197013-Apr-10 8:49 
GeneralRe: Custom dropdown for CComboBox Pin
Code-o-mat13-Apr-10 9:15
Code-o-mat13-Apr-10 9:15 
QuestionConverting an image into jpeg format Pin
Srivathsa_12-Apr-10 20:57
Srivathsa_12-Apr-10 20:57 
AnswerRe: Converting an image into jpeg format Pin
Vijjuuu.12-Apr-10 21:06
Vijjuuu.12-Apr-10 21:06 
GeneralRe: Converting an image into jpeg format Pin
Iain Clarke, Warrior Programmer12-Apr-10 23:20
Iain Clarke, Warrior Programmer12-Apr-10 23:20 
GeneralRe: Converting an image into jpeg format Pin
CPallini12-Apr-10 23:35
mveCPallini12-Apr-10 23:35 
GeneralRe: Converting an image into jpeg format Pin
Vijjuuu.12-Apr-10 23:40
Vijjuuu.12-Apr-10 23:40 
GeneralRe: Converting an image into jpeg format Pin
CPallini12-Apr-10 23:47
mveCPallini12-Apr-10 23:47 
AnswerRe: Converting an image into jpeg format Pin
Cedric Moonen12-Apr-10 21:12
Cedric Moonen12-Apr-10 21:12 

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.