J
jake
I am new to multi-threading. Here is my scenario:
foreach (<file in a certain folder>)
new Thread((ThreadStart)(delegate { processFile(<file>); })).Start();
sometimes misses firing some threads to process files. It misses
firing different threads every time I run it. I suppose it all
depends on the time-slice it is getting at that moment (or I may be
way off base here). What I mean by "misses" is that the "foreach"
loop appears to have executed the thread-start line but the thread
never actually starts.
Can someone please tell me what I can add to the code to make sure
that a thread is started and not missed?
Checking a flag that a thread sets when it first starts is an obvious
solution, but I am looking for a more language native way (if one
exists).
Your help is greatly appreciated.
jake
foreach (<file in a certain folder>)
new Thread((ThreadStart)(delegate { processFile(<file>); })).Start();
sometimes misses firing some threads to process files. It misses
firing different threads every time I run it. I suppose it all
depends on the time-slice it is getting at that moment (or I may be
way off base here). What I mean by "misses" is that the "foreach"
loop appears to have executed the thread-start line but the thread
never actually starts.
Can someone please tell me what I can add to the code to make sure
that a thread is started and not missed?
Checking a flag that a thread sets when it first starts is an obvious
solution, but I am looking for a more language native way (if one
exists).
Your help is greatly appreciated.
jake