Click here to Skip to main content
16,005,389 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Can FindFirstFile/FindNextFile be multithread? Pin
Naveen10-Dec-06 22:41
Naveen10-Dec-06 22:41 
AnswerRe: Can FindFirstFile/FindNextFile be multithread? Pin
Waldermort10-Dec-06 22:55
Waldermort10-Dec-06 22:55 
AnswerRe: Can FindFirstFile/FindNextFile be multithread? Pin
Hamid_RT10-Dec-06 23:15
Hamid_RT10-Dec-06 23:15 
GeneralRe: Can FindFirstFile/FindNextFile be multithread? [modified] Pin
rgbalpha11-Dec-06 0:42
rgbalpha11-Dec-06 0:42 
QuestionRe: Can FindFirstFile/FindNextFile be multithread? Pin
David Crow11-Dec-06 3:24
David Crow11-Dec-06 3:24 
AnswerRe: Can FindFirstFile/FindNextFile be multithread? Pin
rgbalpha11-Dec-06 17:03
rgbalpha11-Dec-06 17:03 
AnswerRe: Can FindFirstFile/FindNextFile be multithread? Pin
Sam Hobbs10-Dec-06 23:41
Sam Hobbs10-Dec-06 23:41 
AnswerRe: Can FindFirstFile/FindNextFile be multithread? Pin
James R. Twine11-Dec-06 4:08
James R. Twine11-Dec-06 4:08 
   It is not safe to have mutiple threads messing with the same find handle as the same time.  It should be safe to first construct the full path to the file and pass it to a thread like you later examples demonstrates, but you have to make sure that the memory pointed to by the filename parameter is valid for as long as the thread needs it.  This is the kind of situation where "hand-off" memory can be used, either by allocating a TCHAR buffer via new[] and passing it to the thread which will later call delete[] on it, or passing a string object.

   For these kinds of situations, you may want to use a pool of threads with something like an I/O Completion Port and throw processing requests at it.  That way, you do not create too many threads bogging the system down (you do not want to create 1500 threads if 1500 files need to be processed), and you can adjust the number of threads in the pool depending on the resources available on the target system and/or the performance needs of the application.

   You can also look into seeing if the QueueUserWorkItem(...) function is available on the target system and use it to manage the thread pool and the work to be done.

   Peace!

-=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites
(Please rate this post!)

GeneralRe: Can FindFirstFile/FindNextFile be multithread? Pin
rgbalpha11-Dec-06 17:09
rgbalpha11-Dec-06 17:09 
Questionfatal error C1189 ?? Pin
Programm3r10-Dec-06 22:13
Programm3r10-Dec-06 22:13 
AnswerRe: fatal error C1189 ?? Pin
Naveen10-Dec-06 22:18
Naveen10-Dec-06 22:18 
GeneralRe: fatal error C1189 ?? Pin
Programm3r10-Dec-06 22:23
Programm3r10-Dec-06 22:23 
GeneralRe: fatal error C1189 ?? Pin
Naveen10-Dec-06 22:25
Naveen10-Dec-06 22:25 
GeneralRe: fatal error C1189 ?? Pin
Programm3r10-Dec-06 22:26
Programm3r10-Dec-06 22:26 
AnswerRe: fatal error C1189 ?? Pin
benjymous10-Dec-06 22:40
benjymous10-Dec-06 22:40 
QuestionDragable Menu Items Pin
benjamin2310-Dec-06 22:01
benjamin2310-Dec-06 22:01 
AnswerRe: Dragable Menu Items Pin
Naveen10-Dec-06 22:09
Naveen10-Dec-06 22:09 
AnswerRe: Dragable Menu Items Pin
benjamin2310-Dec-06 22:18
benjamin2310-Dec-06 22:18 
GeneralRe: Dragable Menu Items Pin
Naveen10-Dec-06 22:26
Naveen10-Dec-06 22:26 
AnswerRe: Dragable Menu Items Pin
Michael Dunn10-Dec-06 22:15
sitebuilderMichael Dunn10-Dec-06 22:15 
GeneralRe: Dragable Menu Items Pin
benjamin2310-Dec-06 22:22
benjamin2310-Dec-06 22:22 
GeneralRe: Dragable Menu Items Pin
benjamin2314-Dec-06 21:11
benjamin2314-Dec-06 21:11 
AnswerRe: Dragable Menu Items Pin
benjamin2310-Dec-06 23:14
benjamin2310-Dec-06 23:14 
QuestionHow to create and use a lib file ? Pin
KEL310-Dec-06 21:51
KEL310-Dec-06 21:51 
AnswerRe: How to create and use a lib file ? Pin
Cedric Moonen10-Dec-06 21:58
Cedric Moonen10-Dec-06 21:58 

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.