Click here to Skip to main content
15,885,309 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Passing data to running thread Pin
Rajesh R Subramanian3-Jul-11 3:57
professionalRajesh R Subramanian3-Jul-11 3:57 
GeneralRe: Passing data to running thread Pin
csrss3-Jul-11 4:45
csrss3-Jul-11 4:45 
GeneralRe: Passing data to running thread Pin
Rajesh R Subramanian3-Jul-11 5:46
professionalRajesh R Subramanian3-Jul-11 5:46 
GeneralRe: Passing data to running thread Pin
Albert Holguin3-Jul-11 7:32
professionalAlbert Holguin3-Jul-11 7:32 
GeneralRe: Passing data to running thread Pin
Mark Salsbery3-Jul-11 7:40
Mark Salsbery3-Jul-11 7:40 
GeneralRe: Passing data to running thread Pin
Rajesh R Subramanian3-Jul-11 8:47
professionalRajesh R Subramanian3-Jul-11 8:47 
GeneralRe: Passing data to running thread Pin
csrss3-Jul-11 9:07
csrss3-Jul-11 9:07 
AnswerRe: Passing data to running thread Pin
Mark Salsbery3-Jul-11 7:44
Mark Salsbery3-Jul-11 7:44 
You don't really need to "pass data to a thread", as all threads in a process have access to the same data.

I typically use a semaphore to signal the worker thread when there's a job to do. The "jobs" are queued in a collection of some sort, and whenever a job is queued, the semaphore's count is incremented, setting its state to signaled. The worker thread waits on the semaphore and pops a job off the queue (don't forget to synchronize access to the collection with a critical section!) and processes it any time the semaphore is signaled.

That's for a single worker thread...If I need a pool of worker threads, I'll use an I/O completion port instead....it does all the above and saves writing alot of thread plumbing code.
Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Passing data to running thread Pin
csrss3-Jul-11 9:03
csrss3-Jul-11 9:03 
AnswerRe: Passing data to running thread Pin
LiangGuangLin3-Jul-11 18:01
LiangGuangLin3-Jul-11 18:01 
QuestionNMAKE Error Pin
SNI2-Jul-11 5:10
SNI2-Jul-11 5:10 
AnswerRe: NMAKE Error Pin
Richard MacCutchan2-Jul-11 6:43
mveRichard MacCutchan2-Jul-11 6:43 
QuestionRe: NMAKE Error Pin
David Crow2-Jul-11 16:53
David Crow2-Jul-11 16:53 
AnswerRe: NMAKE Error Pin
SNI3-Jul-11 5:41
SNI3-Jul-11 5:41 
AnswerRe: NMAKE Error Pin
User 74293383-Jul-11 5:47
professionalUser 74293383-Jul-11 5:47 
GeneralRe: NMAKE Error [modified] Pin
SNI11-Jul-11 1:49
SNI11-Jul-11 1:49 
GeneralRe: NMAKE Error Pin
David Crow5-Jul-11 2:55
David Crow5-Jul-11 2:55 
Questionconverting chinese .rc file to english .rc file Pin
Sakhalean2-Jul-11 3:44
Sakhalean2-Jul-11 3:44 
AnswerRe: converting chinese .rc file to english .rc file Pin
«_Superman_»2-Jul-11 10:24
professional«_Superman_»2-Jul-11 10:24 
GeneralRe: converting chinese .rc file to english .rc file Pin
Albert Holguin3-Jul-11 7:29
professionalAlbert Holguin3-Jul-11 7:29 
AnswerRe: converting chinese .rc file to english .rc file Pin
Dr.Walt Fair, PE2-Jul-11 19:17
professionalDr.Walt Fair, PE2-Jul-11 19:17 
QuestionIs this possible String Encryptin result contains only alphanumric value using Base64. Pin
Le@rner2-Jul-11 2:05
Le@rner2-Jul-11 2:05 
AnswerRe: Is this possible String Encryptin result contains only alphanumric value using Base64. Pin
Philippe Mori2-Jul-11 12:30
Philippe Mori2-Jul-11 12:30 
AnswerRe: Is this possible String Encryptin result contains only alphanumric value using Base64. Pin
Dr.Walt Fair, PE2-Jul-11 18:37
professionalDr.Walt Fair, PE2-Jul-11 18:37 
AnswerRe: Is this possible String Encryptin result contains only alphanumric value using Base64. Pin
Randor 4-Jul-11 3:34
professional Randor 4-Jul-11 3: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.