I expect there are many possible solutions to this question, I can come up a few myself, some clearly better than others but none that I am certain are optimal so I'm interested in hearing from you real multi threading gurus out there.
I have circa 100 pieces of work that can be executed concurrently as there are no dependencies between them. If I execute these sequentially my total execution time is approx 1:30s. If I queue each piece of work in the thread pool it takes approx 2m, which suggests to me that I am trying to do too much at once and context switching between all these threads is negating the advantage of having those threads.
So based on the assumption (please feel free to shoot me down if this is wrong) that if I only queue up to the number of cores in my system (8 on this machine) pieces of work at any one time I will reduce context switching and thus improve overall efficiency (other process threads not withstanding of course), can anyone suggest the optimal pattern/technique for doing this?
BTW I am using smartthreadpool.codeplex.com, but I don't have to.