Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help with compile error Pin
mark novak8-Jun-05 15:22
mark novak8-Jun-05 15:22 
Generalpointer question Pin
jee858-Jun-05 11:05
sussjee858-Jun-05 11:05 
GeneralRe: pointer question Pin
mark novak8-Jun-05 14:54
mark novak8-Jun-05 14:54 
GeneralIActiveDesktop Pin
neliocc8-Jun-05 10:43
neliocc8-Jun-05 10:43 
GeneralRe: IActiveDesktop Pin
mark novak8-Jun-05 15:29
mark novak8-Jun-05 15:29 
GeneralRe: IActiveDesktop Pin
neliocc8-Jun-05 16:50
neliocc8-Jun-05 16:50 
GeneralRe: IActiveDesktop Pin
ThatsAlok8-Jun-05 18:51
ThatsAlok8-Jun-05 18:51 
GeneralQuestion RE. CriticalSection Pin
Budric B.8-Jun-05 10:26
Budric B.8-Jun-05 10:26 
Hi,
I'm sharing an object between 2 threads and I need to synchronize it. The following is a model of my code:

<br />
class SynchronizedObject<br />
{<br />
<pre>SynchronizedObject()  //constructor<br />
{<br />
InitializeCriticalSection(&m_ThreadSynch);<br />
}<br />
<br />
CRITICAL_SECTION m_ThreadSynch;<br />
void Lock()<br />
{<br />
::EnterCriticalSection(&m_ThreadSynch);<br />
}<br />
void Unlock()<br />
{<br />
::LeaveCriticalSection(&m_ThreadSynch);<br />
}</pre><br />
<br />
//now the functions with problem<br />
void A()<br />
{<br />
Lock();<br />
B();<br />
Unlock();<br />
}<br />
<br />
void B()<br />
{<br />
Lock();<br />
//do some stuff<br />
Unlock();<br />
}<br />
};<br />


For some reason when I call A() my code doesn't lock up. Am I using the Critical Section incorrectly? Or does it check which thread is trying to enter the critical section and allows the same thread to enter it multiple times (which I thought wasn't the case). What about Mutexes? Aside from synchronizing accross processes do they behave differently? What about Semaphores?

Note: I've also tried to just put a member object CCriticalSection synch; and call synch.Lock()/Unlock() where appropriate. Same result.
GeneralRe: Question RE. CriticalSection Pin
Blake Miller8-Jun-05 11:21
Blake Miller8-Jun-05 11:21 
GeneralRe: Question RE. CriticalSection Pin
Axter8-Jun-05 18:52
professionalAxter8-Jun-05 18:52 
GeneralRe: Question RE. CriticalSection Pin
Bob Stanneveld8-Jun-05 20:53
Bob Stanneveld8-Jun-05 20:53 
GeneralRe: thanks Pin
Budric B.9-Jun-05 3:13
Budric B.9-Jun-05 3:13 
GeneralSHBrowseForFolder question Pin
Lynsen8-Jun-05 10:18
Lynsen8-Jun-05 10:18 
GeneralRe: SHBrowseForFolder question Pin
mark novak8-Jun-05 15:20
mark novak8-Jun-05 15:20 
GeneralCreating ODBC source Pin
Richard Jones8-Jun-05 9:50
Richard Jones8-Jun-05 9:50 
GeneralRe: Creating ODBC source Pin
Tom Archer8-Jun-05 10:10
Tom Archer8-Jun-05 10:10 
GeneralRe: Creating ODBC source Pin
Richard Jones9-Jun-05 2:24
Richard Jones9-Jun-05 2:24 
GeneralFont Style in CListCtrl Pin
RickyC8-Jun-05 9:32
RickyC8-Jun-05 9:32 
GeneralRe: Font Style in CListCtrl Pin
mark novak8-Jun-05 15:00
mark novak8-Jun-05 15:00 
GeneralRe: Font Style in CListCtrl Pin
RickyC9-Jun-05 2:02
RickyC9-Jun-05 2:02 
GeneralTrying to load bitmap from a path in GDI+ Pin
Anonymous8-Jun-05 8:05
Anonymous8-Jun-05 8:05 
GeneralRe: Trying to load bitmap from a path in GDI+ Pin
PJ Arends8-Jun-05 9:27
professionalPJ Arends8-Jun-05 9:27 
GeneralRe: Trying to load bitmap from a path in GDI+ Pin
Tom Archer8-Jun-05 10:15
Tom Archer8-Jun-05 10:15 
GeneralRe: Trying to load bitmap from a path in GDI+ Pin
Anonymous8-Jun-05 11:50
Anonymous8-Jun-05 11:50 
GeneralGet resources strings Pin
Kaworu28-Jun-05 6:34
Kaworu28-Jun-05 6:34 

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.