Click here to Skip to main content
15,844,011 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

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