Click here to Skip to main content
15,914,162 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CListBox problem... Pin
Mirelutza20-May-04 21:44
Mirelutza20-May-04 21:44 
GeneralCatch Return Key in CListBox Pin
aturki20-May-04 5:39
aturki20-May-04 5:39 
GeneralRe: Catch Return Key in CListBox Pin
Iain Clarke, Warrior Programmer20-May-04 5:59
Iain Clarke, Warrior Programmer20-May-04 5:59 
GeneralRe: Catch Return Key in CListBox Pin
Andrew Quinn AUS20-May-04 6:06
Andrew Quinn AUS20-May-04 6:06 
GeneralUse pipe without WriteFile Func Pin
Anonymous20-May-04 5:39
Anonymous20-May-04 5:39 
GeneralRe: Use pipe without WriteFile Func Pin
valikac20-May-04 6:10
valikac20-May-04 6:10 
GeneralRe: Use pipe without WriteFile Func Pin
Member 42102520-May-04 6:32
Member 42102520-May-04 6:32 
GeneralLong Wait for a Mutex Pin
sweep12320-May-04 5:27
sweep12320-May-04 5:27 
Can someone tell me if I have got this scheme correct for using Mutex's for controlling access to shared data (memory mapped) between two programs.

Each program creates the Mutex as follows:-

m_hMutex = ::CreateMutex(NULL,FALSE,"CSLSharedMemLock");

Each program uses the following procedure before read/write operations:-

<big>bool WaitForMutex(void)<br />
{<br />
/* This procedure will wait for a Mutex before allowing any<br />
write access to the shared area. */<br />
<br />
if(m_hMutex)<br />
{<br />
   if (::WaitForSingleObject(m_hMutex,INFINITE) == WAIT_OBJECT_0)<br />
   {<br />
      return true;<br />
   }<br />
   return false;<br />
}</big>


then we read data or write data and release the handle.

<big>ReleaseMutex(m_hMutex);</big>
and then

<big>CloseHandle (m_hMutex);</big>
The 2 programs (EXE and DLL) work OK without using the Mutex, but lock up as soon as I start to use a Mutex; i.e. never return from WaitForMutex in the EXE program.

I did check the value of the HANDLE and were as follows:-

In the DLL 0x00000084 and in the EXE 0x00000128 and the Mutex name is the same in both.

I want to protect the shared data, any comments?
GeneralRe: Long Wait for a Mutex Pin
valikac20-May-04 6:14
valikac20-May-04 6:14 
GeneralRe: Long Wait for a Mutex Pin
sweep12320-May-04 6:21
sweep12320-May-04 6:21 
GeneralRe: Long Wait for a Mutex Pin
valikac20-May-04 6:31
valikac20-May-04 6:31 
GeneralRe: Long Wait for a Mutex Pin
sweep12320-May-04 6:36
sweep12320-May-04 6:36 
GeneralRe: Long Wait for a Mutex Pin
valikac20-May-04 6:45
valikac20-May-04 6:45 
GeneralRe: Long Wait for a Mutex Pin
Grahamfff20-May-04 10:18
Grahamfff20-May-04 10:18 
GeneralRe: Long Wait for a Mutex Pin
Paul Ranson20-May-04 10:34
Paul Ranson20-May-04 10:34 
GeneralRe: Long Wait for a Mutex Pin
Grahamfff20-May-04 10:45
Grahamfff20-May-04 10:45 
GeneralRe: Long Wait for a Mutex Pin
Paul Ranson20-May-04 11:34
Paul Ranson20-May-04 11:34 
GeneralRe: Long Wait for a Mutex Pin
valikac20-May-04 11:24
valikac20-May-04 11:24 
GeneralBitwise Left Shift Pin
Anthony988720-May-04 5:08
Anthony988720-May-04 5:08 
GeneralRe: Bitwise Left Shift Pin
Michael Dunn20-May-04 5:13
sitebuilderMichael Dunn20-May-04 5:13 
GeneralRe: Bitwise Left Shift Pin
Antony M Kancidrowski20-May-04 5:26
Antony M Kancidrowski20-May-04 5:26 
GeneralRe: Bitwise Left Shift Pin
mirex20-May-04 21:39
mirex20-May-04 21:39 
GeneralRe: Bitwise Left Shift Pin
Antony M Kancidrowski20-May-04 5:25
Antony M Kancidrowski20-May-04 5:25 
GeneralRe: Bitwise Left Shift Pin
deniz79s20-May-04 9:01
deniz79s20-May-04 9:01 
GeneralIt is illegal to call out while inside message filter Pin
Member 53435720-May-04 4:55
Member 53435720-May-04 4:55 

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.