Click here to Skip to main content
16,007,885 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Mouse Cursor Drawing Resolution Pin
Alexander Wiseman19-Jul-04 15:47
Alexander Wiseman19-Jul-04 15:47 
GeneralRe: Mouse Cursor Drawing Resolution Pin
Alexander Wiseman19-Jul-04 15:56
Alexander Wiseman19-Jul-04 15:56 
GeneralRe: Mouse Cursor Drawing Resolution Pin
User 1278220-Jul-04 11:28
User 1278220-Jul-04 11:28 
GeneralRe: Mouse Cursor Drawing Resolution Pin
Alexander Wiseman20-Jul-04 11:34
Alexander Wiseman20-Jul-04 11:34 
GeneralRe: Mouse Cursor Drawing Resolution Pin
gamitech19-Jul-04 12:03
gamitech19-Jul-04 12:03 
GeneralRe: Mouse Cursor Drawing Resolution Pin
User 1278219-Jul-04 12:24
User 1278219-Jul-04 12:24 
GeneralRe: Mouse Cursor Drawing Resolution Pin
gamitech19-Jul-04 13:11
gamitech19-Jul-04 13:11 
GeneralThreading... Pin
0v3rloader19-Jul-04 7:37
0v3rloader19-Jul-04 7:37 
Hello,

This time the question if about threading... hope you'll appreciate it.

Well then, I have a worker thread being created at some point in my App. It happens that this [new] thread creates about 5 modeless dialogs which continuously output data. This thread was derived from CWinThread; Everything fine so far...

Now, this is where it gets tricky: inside the InitInstance I initialise a class, which has no links whatsoever to a message pump nor to the main frame window. Moreover, it has to execute in a kind of a loop. Here's an example:

BOOL CClass::InitInstance()
{
	CG1	theG1;

	// init dialogs
	// init controls, etc

	theG1.Run();		// lets make the emulator run the program then
	
	// it exited...
	// de-init everything
	return FALSE;
}


This was my first (frustrated) attempt and I quickly learned that whenever the instruction execution reached inside theG1.Run, there were no Windows Messages being received/processed.

So I made some changes. Instead of having it run inside InitInstance, I implemented a solution with OnIdle. I don't really like it, but let's see how I did it:

CClass::OnIdle(long nCount)
{
	// execute the next instruction
	theG1.ExecuteNext();	// had to decompose <code>Run</code> into ExecuteNext()
	// lets return and ask for more
	// processing time
	return TRUE;
}


Now my question:

Is is possible to make the class run in a real multi-threading environment rather than in OnIdle? I know I would have to somehow make a connection with the thread's Message Pump... but how?

Any suggestions would be greatly appreciated,

David

PS: In case you got confused with the methods I'm using above (Run; ExecuteNext) , I am working on an academic project aimed at emulating a processor on a x86 machine.
GeneralRe: Threading... Pin
David Crow19-Jul-04 9:17
David Crow19-Jul-04 9:17 
GeneralRe: Threading... Pin
0v3rloader19-Jul-04 22:53
0v3rloader19-Jul-04 22:53 
GeneralDatabase Application Performance Pin
Sridhar Sanikommu19-Jul-04 7:01
Sridhar Sanikommu19-Jul-04 7:01 
GeneralRe: Database Application Performance Pin
G. Steudtel19-Jul-04 7:10
G. Steudtel19-Jul-04 7:10 
GeneralRe: Database Application Performance Pin
Ivan Cachicatari19-Jul-04 7:12
Ivan Cachicatari19-Jul-04 7:12 
GeneralRe: Database Application Performance Pin
Alexander Wiseman19-Jul-04 7:25
Alexander Wiseman19-Jul-04 7:25 
GeneralRe: Database Application Performance Pin
Sridhar Sanikommu19-Jul-04 7:35
Sridhar Sanikommu19-Jul-04 7:35 
GeneralRe: Database Application Performance Pin
Alexander Wiseman19-Jul-04 10:14
Alexander Wiseman19-Jul-04 10:14 
GeneralRe: Database Application Performance Pin
Sridhar Sanikommu19-Jul-04 11:28
Sridhar Sanikommu19-Jul-04 11:28 
GeneralRe: Database Application Performance Pin
Alexander Wiseman19-Jul-04 15:52
Alexander Wiseman19-Jul-04 15:52 
GeneralRe: Database Application Performance Pin
Anonymous19-Jul-04 16:36
Anonymous19-Jul-04 16:36 
GeneralRe: Database Application Performance Pin
Sridhar Sanikommu19-Jul-04 16:38
Sridhar Sanikommu19-Jul-04 16:38 
GeneralRe: Database Application Performance Pin
Steen Krogsgaard19-Jul-04 23:01
Steen Krogsgaard19-Jul-04 23:01 
GeneralFinding files recursively Pin
Ivan Cachicatari19-Jul-04 6:55
Ivan Cachicatari19-Jul-04 6:55 
GeneralRe: Finding files recursively Pin
Alexander Wiseman19-Jul-04 7:21
Alexander Wiseman19-Jul-04 7:21 
GeneralRe: Finding files recursively Pin
gamitech19-Jul-04 12:07
gamitech19-Jul-04 12:07 
Generalgetting userID Pin
maggi198119-Jul-04 6:41
sussmaggi198119-Jul-04 6:41 

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.