Go Back   AnandTech Forums > Software > Programming

Forums
· Hardware and Technology
· CPUs and Overclocking
· Motherboards
· Video Cards and Graphics
· Memory and Storage
· Power Supplies
· Cases & Cooling
· SFF, Notebooks, Pre-Built/Barebones PCs
· Networking
· Peripherals
· General Hardware
· Highly Technical
· Computer Help
· Home Theater PCs
· Consumer Electronics
· Digital and Video Cameras
· Mobile Devices & Gadgets
· Audio/Video & Home Theater
· Software
· Software for Windows
· All Things Apple
· *nix Software
· Operating Systems
· Programming
· PC Gaming
· Console Gaming
· Distributed Computing
· Security
· Social
· Off Topic
· Politics and News
· Discussion Club
· Love and Relationships
· The Garage
· Health and Fitness
· Merchandise and Shopping
· For Sale/Trade
· Hot Deals with Free Stuff/Contests
· Black Friday 2014
· Forum Issues
· Technical Forum Issues
· Personal Forum Issues
· Suggestion Box
· Moderator Resources
· Moderator Discussions
   

Reply
 
Thread Tools
Old 01-16-2013, 12:36 PM   #1
EagleKeeper
Discussion Club Moderator
Elite Member
 
EagleKeeper's Avatar
 
Join Date: Oct 2000
Location: Bumps west of Denver
Posts: 42,600
Default Events - Win32 vs MFC apps

Background
Building emulators for H/W that is delayed 6 months
Using shared memory and events controlling the threads using the shared memory on a Win 7 system

Single class, SharedMemory, creates memory mapped file, maps the buffer and create events.
This class is shared/used by two programs (common code). It builds the memory mapped files and events and code to trigger the events.

Each program has a "receiving thread" that uses a pulsed event when data is available in the shared memory buffer.

When I build both programs with MFC, they are able to talk with each other; raising events and passing data via the memory mapped files.

Then I rebuild one program for Win32 (eventual target is WinCE), going backward from MFC to Win32 is a bitch when having to remap control messages , using the same Shared Memory class - code untouched.

Now, the events raised by the MFC app are not being seen by the Win32 app.

Using the debugger, I have a breakpoint after the WaitForSingleObject call to the defined event, m_ghEventRecv. Never gets tripped on the Win32app, yet the MFC equivalent is fine.

Theories!!

Code:
static DWORD WINAPI SPI_Thread(LPVOID lParam)
{
   while (true)
   {
      WaitForSingleObject(mySelf->m_SharedMemory.m_ghEventRecv,INFINITE);
      mySelf->OnGas_UI_Message(0,0);
   }
}
__________________
F15 Air Superiority Fighter - Never has one been lost in aerial combat (104 kills)

Last edited by EagleKeeper; 01-16-2013 at 08:47 PM.
EagleKeeper is offline   Reply With Quote
Old 01-16-2013, 02:44 PM   #2
brandonb
Diamond Member
 
Join Date: Oct 2006
Posts: 3,487
Default

How is :

mySelf>m_SharedMemory.m_ghEventRecv

Declared?

Also, make sure INFINITE is the same value in both MFC and Win32. Maybe hard code to -1 or whatever the infinite value is.
__________________
Computer Setup
Intel Ivy Bridge 3550, AsRock Z75 Pro3, 8 gig GSkill 1600 8-8-8-24 timing, Crucial m4 64gig, 500meg WD RE4, ATI 7970 3GB, LG IPS236V x 3, Windows 8, Antec Sonata Solo 2, Antec 550watt PS.
brandonb is offline   Reply With Quote
Old 01-16-2013, 04:21 PM   #3
EagleKeeper
Discussion Club Moderator
Elite Member
 
EagleKeeper's Avatar
 
Join Date: Oct 2000
Location: Bumps west of Denver
Posts: 42,600
Default

Quote:
Originally Posted by brandonb View Post
How is :

mySelf->m_SharedMemory.m_ghEventRecv

Declared?

Also, make sure INFINITE is the same value in both MFC and Win32. Maybe hard code to -1 or whatever the infinite value is.
HANDLE m_ghEventRecv;

I will check on both HANDLE and INFINITE

Thanks
__________________
F15 Air Superiority Fighter - Never has one been lost in aerial combat (104 kills)

Last edited by EagleKeeper; 01-16-2013 at 08:47 PM.
EagleKeeper is offline   Reply With Quote
Old 01-16-2013, 04:57 PM   #4
Schmide
Diamond Member
 
Schmide's Avatar
 
Join Date: Mar 2002
Posts: 4,256
Default

is this a typo?

Code:
mySelf>m_SharedMemory.m_ghEventRecv
Logical mySelf greater than m_SharedMemory.m_ghEventRecv resolving to 0 or 1

Code:
mySelf->m_SharedMemory.m_ghEventRecv
Pointer mySelf to m_SharedMemory.m_ghEventRecv
__________________
All errors are undocumented features waiting to be discovered.
Schmide is online now   Reply With Quote
Old 01-16-2013, 08:42 PM   #5
EagleKeeper
Discussion Club Moderator
Elite Member
 
EagleKeeper's Avatar
 
Join Date: Oct 2000
Location: Bumps west of Denver
Posts: 42,600
Default

Quote:
Originally Posted by Schmide View Post
is this a typo?

Code:
mySelf>m_SharedMemory.m_ghEventRecv
Logical mySelf greater than m_SharedMemory.m_ghEventRecv resolving to 0 or 1

Code:
mySelf->m_SharedMemory.m_ghEventRecv
Pointer mySelf to m_SharedMemory.m_ghEventRecv
Somehow the copy/paste lost the right facing arrow from myself->
m_SharedMemory is the variable for SharedMemory class.
m_ghEventRecv is the Handle to the Event object.
__________________
F15 Air Superiority Fighter - Never has one been lost in aerial combat (104 kills)

Last edited by EagleKeeper; 01-16-2013 at 08:46 PM.
EagleKeeper is offline   Reply With Quote
Old 01-16-2013, 08:51 PM   #6
Markbnj
Moderator
Programming
 
Markbnj's Avatar
 
Join Date: Sep 2005
Posts: 12,855
Default

Hmm, well the thing is there are an asston of differences between a Win32 program and a MFC program, and a lot of those differences could be affecting an issue like this. You say you "built" for Win32, but of course it's not that easy. Your Win32 program has to have a completely different structure than your MFC program. Where's your message pump, for example?
__________________
Everytime I try to tell you, the words just come out wrong

**
Some meaningless scribbling of no account

The 4th Realm

Arts and Letters Daily - Get some culture
Markbnj is online now   Reply With Quote
Old 01-17-2013, 08:21 PM   #7
EagleKeeper
Discussion Club Moderator
Elite Member
 
EagleKeeper's Avatar
 
Join Date: Oct 2000
Location: Bumps west of Denver
Posts: 42,600
Default

Message pump for Win32 is the standard WinProc handler shown in a generic Windows programming book from the late 80s early 90s.

The problem is not the message pump, but the creation/detection of user defined events
__________________
F15 Air Superiority Fighter - Never has one been lost in aerial combat (104 kills)
EagleKeeper is offline   Reply With Quote
Old 01-17-2013, 09:58 PM   #8
Markbnj
Moderator
Programming
 
Markbnj's Avatar
 
Join Date: Sep 2005
Posts: 12,855
Default

Quote:
Originally Posted by EagleKeeper View Post
Message pump for Win32 is the standard WinProc handler shown in a generic Windows programming book from the late 80s early 90s.

The problem is not the message pump, but the creation/detection of user defined events
Yeah it was just the way you described what I would think of as a port. An MFC program and a Win32 program are two different programs, and it seemed strange to talk of building the same source both ways.

Anyway, events go through the message pump ultimately, but as long as you have a standard getmessage loop then I'm sure that parts all good.
__________________
Everytime I try to tell you, the words just come out wrong

**
Some meaningless scribbling of no account

The 4th Realm

Arts and Letters Daily - Get some culture
Markbnj is online now   Reply With Quote
Reply

Tags
events, win32 mfc

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.