Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problems synchronizing multiple threads?? Pin
Graham Bradshaw27-Jun-06 11:46
Graham Bradshaw27-Jun-06 11:46 
GeneralRe: Problems synchronizing multiple threads?? Pin
Jun Du28-Jun-06 3:45
Jun Du28-Jun-06 3:45 
GeneralRe: Problems synchronizing multiple threads?? Pin
John M. Drescher28-Jun-06 7:06
John M. Drescher28-Jun-06 7:06 
GeneralRe: Problems synchronizing multiple threads?? Pin
Jun Du28-Jun-06 9:03
Jun Du28-Jun-06 9:03 
GeneralRe: Problems synchronizing multiple threads?? Pin
led mike27-Jun-06 9:18
led mike27-Jun-06 9:18 
GeneralRe: Problems synchronizing multiple threads?? [modified] Pin
Zac Howland27-Jun-06 9:31
Zac Howland27-Jun-06 9:31 
GeneralRe: Problems synchronizing multiple threads?? Pin
mikeorama1234527-Jun-06 9:53
mikeorama1234527-Jun-06 9:53 
GeneralRe: Problems synchronizing multiple threads?? Pin
Zac Howland27-Jun-06 10:12
Zac Howland27-Jun-06 10:12 
You mean something like this:

Main Thread
<br />
struct myData<br />
{<br />
  shared_ptr<CCriticalSection> ptr;<br />
};<br />
<br />
void main()<br />
{<br />
  shared_ptr<CCriticalSection> mySection(new CCriticalSection);<br />
  myData data;<br />
  data.ptr = mySection;<br />
  HANDLE hThreads[2];<br />
  hThreads[0] = CreateThread(..., &data); // Thread 1<br />
  hThreads[1] = CreateThread(..., &data); // Thread 2<br />
<br />
  while (WaitForMultipleObjects(...) == WAIT_TIMEOUT)<br />
  {<br />
     // do something<br />
  }<br />
}<br />


Threads 1 and 2
int Thread1(LPARAM pParam)<br />
{<br />
   myData data = *(myData*)pParam;<br />
   shared_ptr<CCriticalSection> mySection = data.ptr;<br />
<br />
   while (IDoSomething())<br />
   {<br />
      mySection->Lock();<br />
      // I do stuff<br />
      mySection->Unlock();<br />
   }<br />
   return 0;<br />
}


Yes, sooo much more clutter ...

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac
GeneralRe: Problems synchronizing multiple threads?? Pin
John M. Drescher27-Jun-06 10:17
John M. Drescher27-Jun-06 10:17 
AnswerRe: Problems synchronizing multiple threads?? Pin
valikac27-Jun-06 9:12
valikac27-Jun-06 9:12 
AnswerRe: Problems synchronizing multiple threads?? Pin
Michael Dunn27-Jun-06 9:47
sitebuilderMichael Dunn27-Jun-06 9:47 
GeneralRe: Problems synchronizing multiple threads?? Pin
pavanbabut29-Jun-06 12:11
pavanbabut29-Jun-06 12:11 
Questionbug of mouse_event() Pin
V_shr27-Jun-06 7:28
V_shr27-Jun-06 7:28 
QuestionCOM Port Acesss in VC++ Pin
tanksali27-Jun-06 6:17
tanksali27-Jun-06 6:17 
AnswerRe: COM Port Acesss in VC++ Pin
David Crow27-Jun-06 6:41
David Crow27-Jun-06 6:41 
AnswerRe: COM Port Acesss in VC++ Pin
mikeorama1234527-Jun-06 8:43
mikeorama1234527-Jun-06 8:43 
AnswerRe: COM Port Acesss in VC++ Pin
Hamid_RT27-Jun-06 19:17
Hamid_RT27-Jun-06 19:17 
QuestionMultiple string tables in exe Pin
Andre xxxxxxx27-Jun-06 6:06
Andre xxxxxxx27-Jun-06 6:06 
AnswerRe: Multiple string tables in exe Pin
Joe Woodbury27-Jun-06 6:15
professionalJoe Woodbury27-Jun-06 6:15 
GeneralRe: Multiple string tables in exe Pin
Andre xxxxxxx27-Jun-06 6:22
Andre xxxxxxx27-Jun-06 6:22 
GeneralRe: Multiple string tables in exe Pin
Joe Woodbury27-Jun-06 6:29
professionalJoe Woodbury27-Jun-06 6:29 
GeneralRe: Multiple string tables in exe Pin
Andre xxxxxxx27-Jun-06 6:35
Andre xxxxxxx27-Jun-06 6:35 
GeneralRe: Multiple string tables in exe Pin
Joe Woodbury27-Jun-06 6:47
professionalJoe Woodbury27-Jun-06 6:47 
GeneralRe: Multiple string tables in exe Pin
Andre xxxxxxx27-Jun-06 8:30
Andre xxxxxxx27-Jun-06 8:30 
AnswerRe: Multiple string tables in exe Pin
Zac Howland27-Jun-06 7:21
Zac Howland27-Jun-06 7:21 

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.