Click here to Skip to main content
15,915,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: OnCmdMsg( ) method Pin
David Crow4-Jun-07 6:56
David Crow4-Jun-07 6:56 
QuestionTwo Context Menu Dlls Are Exhibiting Mutually Exclusive Behavior Pin
Jeffrey Walton4-Jun-07 5:55
Jeffrey Walton4-Jun-07 5:55 
AnswerRe: Two Context Menu Dlls Are Exhibiting Mutually Exclusive Behavior Pin
Jeffrey Walton4-Jun-07 14:28
Jeffrey Walton4-Jun-07 14:28 
Questionhow to get the device id of a pocket pc Pin
reyd_todo4-Jun-07 5:54
reyd_todo4-Jun-07 5:54 
QuestionHandling of multiple threads Pin
zudroj4-Jun-07 4:02
zudroj4-Jun-07 4:02 
AnswerRe: Handling of multiple threads Pin
Mark Salsbery4-Jun-07 4:35
Mark Salsbery4-Jun-07 4:35 
GeneralRe: Handling of multiple threads Pin
zudroj4-Jun-07 21:20
zudroj4-Jun-07 21:20 
GeneralRe: Handling of multiple threads Pin
Mark Salsbery5-Jun-07 4:26
Mark Salsbery5-Jun-07 4:26 
zudroj wrote:
If I use Mutex, it must be defined outside the ThreadFunction(). Am I right?


Not always. If more than one thread in your process needs to use the mutex, then you need its
handle outside the threadproc, somewhere where other threads can access it.

If the mutex is used only by that thread in the process (for example, a named mutex for
synchronizing different processes) then you could create/open it IN the threadproc.

Define it wherever it can be accessed by all threads that need the handle.

zudroj wrote:
If I need to wait until other thread stopped using of critical part of code, what should I use? WaitForSingleObject() function?


Yes. When WaitForSingleObject() returns and indicates you own the mutex, make sure to call
ReleaseMutex() when you're done executing critical code so other threads can assume ownership of
the mutex.

Mark


"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

GeneralRe: Handling of multiple threads Pin
zudroj5-Jun-07 21:36
zudroj5-Jun-07 21:36 
AnswerRe: Handling of multiple threads Pin
CPallini4-Jun-07 5:05
mveCPallini4-Jun-07 5:05 
QuestionCreating a color table Pin
TheDelChop4-Jun-07 2:50
TheDelChop4-Jun-07 2:50 
AnswerRe: Creating a color table Pin
CPallini4-Jun-07 3:57
mveCPallini4-Jun-07 3:57 
QuestionSpecific editing of a CString Pin
jasn Smith4-Jun-07 2:50
jasn Smith4-Jun-07 2:50 
AnswerRe: Specific editing of a CString Pin
_AnsHUMAN_ 4-Jun-07 3:10
_AnsHUMAN_ 4-Jun-07 3:10 
AnswerRe: Specific editing of a CString Pin
David Crow4-Jun-07 3:29
David Crow4-Jun-07 3:29 
QuestionFont Size Displays [modified] Pin
_AnsHUMAN_ 4-Jun-07 2:48
_AnsHUMAN_ 4-Jun-07 2:48 
AnswerRe: Font Size Displays Pin
Arman S.4-Jun-07 3:15
Arman S.4-Jun-07 3:15 
GeneralRe: Font Size Displays [modified] Pin
_AnsHUMAN_ 4-Jun-07 3:24
_AnsHUMAN_ 4-Jun-07 3:24 
AnswerRe: Font Size Displays Pin
Mark Salsbery4-Jun-07 4:47
Mark Salsbery4-Jun-07 4:47 
Questionsubclassing an activex control in mfc [modified] Pin
dkmr4-Jun-07 2:27
dkmr4-Jun-07 2:27 
AnswerRe: subclassing an activex control in mfc Pin
Naveen4-Jun-07 15:54
Naveen4-Jun-07 15:54 
Questionhow to make an indicator Pin
bigphish4-Jun-07 2:14
bigphish4-Jun-07 2:14 
AnswerRe: how to make an indicator Pin
David Crow4-Jun-07 3:32
David Crow4-Jun-07 3:32 
GeneralRe: how to make an indicator Pin
vivekphlp4-Jun-07 23:38
vivekphlp4-Jun-07 23:38 
GeneralRe: how to make an indicator Pin
David Crow5-Jun-07 2:37
David Crow5-Jun-07 2:37 

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.