just want some advice on \"best practice\" regarding multi-threading tasks.
as an example, we have a C# application that upon startup reads data from various \"type
I like @Reed's solution. Another way to accomplish the same in .NET 4.0 would be to use a CountdownEvent.
class Program
{
static void Main(string[] args)
{
var numThreads = 10;
var countdownEvent = new CountdownEvent(numThreads);
// Start workers.
for (var i = 0; i < numThreads; i++)
{
new Thread(delegate()
{
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
// Signal the CountdownEvent.
countdownEvent.Signal();
}).Start();
}
// Wait for workers.
countdownEvent.Wait();
Console.WriteLine("Finished.");
}
}