Click here to Skip to main content
15,919,358 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to Hide windows Pin
Max++5-Oct-06 6:41
Max++5-Oct-06 6:41 
AnswerRe: How to Hide windows Pin
toxcct5-Oct-06 6:48
toxcct5-Oct-06 6:48 
GeneralRe: How to Hide windows Pin
Max++5-Oct-06 6:57
Max++5-Oct-06 6:57 
AnswerRe: How to Hide windows Pin
David Crow5-Oct-06 7:02
David Crow5-Oct-06 7:02 
AnswerRe: How to Hide windows Pin
Eric Dahlvang5-Oct-06 8:06
Eric Dahlvang5-Oct-06 8:06 
AnswerRe: How to Hide windows Pin
Hamid_RT5-Oct-06 8:37
Hamid_RT5-Oct-06 8:37 
AnswerRe: How to Hide windows Pin
led mike5-Oct-06 10:29
led mike5-Oct-06 10:29 
QuestionEnterCriticalSection() exception issue Pin
Tnarol5-Oct-06 3:43
Tnarol5-Oct-06 3:43 
Hi,

I have a multithreaded program in which I use the following class object "ClassLock" the synchronize accesses :
<br />
#ifndef CLASSLOCK_H<br />
#define CLASSLOCK_H<br />
<br />
extern CRITICAL_SECTION g_ClassLock;<br />
<br />
class ClassLock<br />
{<br />
public:<br />
	static void InitCriticalSection();<br />
	static void DelCriticalSection();<br />
	inline ClassLock()  { EnterCriticalSection( &g_ClassLock );  }<br />
	inline ~ClassLock() { LeaveCriticalSection( &g_ClassLock ); }<br />
};<br />
<br />
#endif


I protect a function call by instantiating a ClassLock object at the beginning of the function :

<br />
void MyFunc()<br />
{<br />
ClassLock l;<br />
...<br />
}<br />



But sometimes, don't know why, an exception is thrown. How can I deal with this ?
My idea would be the following modification, but I don't know if it's safe and smart :

<br />
inline ClassLock()  { while(!TryEnterCriticalSection( &g_ClassLock )) { } }<br />


Any other ideas ? Thanks
AnswerRe: EnterCriticalSection() exception issue Pin
led mike5-Oct-06 4:32
led mike5-Oct-06 4:32 
GeneralRe: EnterCriticalSection() exception issue Pin
Tnarol5-Oct-06 4:54
Tnarol5-Oct-06 4:54 
GeneralRe: EnterCriticalSection() exception issue Pin
led mike5-Oct-06 5:06
led mike5-Oct-06 5:06 
GeneralRe: EnterCriticalSection() exception issue Pin
Tnarol5-Oct-06 5:36
Tnarol5-Oct-06 5:36 
GeneralRe: EnterCriticalSection() exception issue Pin
led mike5-Oct-06 6:13
led mike5-Oct-06 6:13 
AnswerRe: EnterCriticalSection() exception issue Pin
Mark Salsbery5-Oct-06 7:35
Mark Salsbery5-Oct-06 7:35 
GeneralRe: EnterCriticalSection() exception issue Pin
Tnarol5-Oct-06 22:07
Tnarol5-Oct-06 22:07 
GeneralRe: EnterCriticalSection() exception issue Pin
Mark Salsbery6-Oct-06 5:08
Mark Salsbery6-Oct-06 5:08 
AnswerRe: EnterCriticalSection() exception issue Pin
Blake Miller6-Oct-06 8:50
Blake Miller6-Oct-06 8:50 
QuestionAbsolute Addresses Pin
Big CDF5-Oct-06 3:39
Big CDF5-Oct-06 3:39 
AnswerRe: Absolute Addresses Pin
David Crow5-Oct-06 3:47
David Crow5-Oct-06 3:47 
GeneralRe: Absolute Addresses Pin
Big CDF5-Oct-06 11:58
Big CDF5-Oct-06 11:58 
GeneralRe: Absolute Addresses Pin
Jörgen Sigvardsson5-Oct-06 13:54
Jörgen Sigvardsson5-Oct-06 13:54 
AnswerRe: Absolute Addresses Pin
kakan5-Oct-06 19:49
professionalkakan5-Oct-06 19:49 
QuestionDoDataExchange Pin
Sonia Horra5-Oct-06 3:38
Sonia Horra5-Oct-06 3:38 
AnswerRe: DoDataExchange Pin
David Crow5-Oct-06 3:48
David Crow5-Oct-06 3:48 
GeneralRe: DoDataExchange Pin
Sonia Horra5-Oct-06 19:19
Sonia Horra5-Oct-06 19:19 

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.