标签云

微信群

扫码加入我们

WeChat QR Code


Do you need the results back in the same order?

2018年09月26日41分52秒

Could you use multiple background workers? create some sort of logic that would take the count of list of strings then create X amount of BWs and divy up each one

2018年09月25日41分52秒

in this case, will there be any race condition in the result collection? after all multiple threads may be executing result.add simultaneously...

2018年09月26日41分52秒

result.add must be thread safe yeah..

2018年09月26日41分52秒

Forgot to mention I need it in .NET 2.0

2018年09月25日41分52秒

Ok, well, then you could look at the Parallel.Foreach sourcecode in reflector... Though I believe there's an entire other layer below it so it won't be a simple copy pasta to get similar functionality in .NET 2.0.

2018年09月25日41分52秒

Parallel extensions are now part of .net 4.0, so no longer a CTP. :)

2018年09月26日41分52秒

And how do you know when it is finished? mmm.

2018年09月25日41分52秒

Could have a ManualResetEvent that the WaitCallback function calls and the main thread WaitOne on.

2018年09月25日41分52秒

Added code to show how you can use MRE to do that.

2018年09月25日41分52秒

What is WaitHandle.WaitAll() for ? I'm getting a NotSupportedException : "The number of WaitHandles must be less than or equal to 64"

2018年09月26日41分52秒

You are generating more than 64 threads... That's probably not a good idea... :) Try with less threads.

2018年09月25日41分52秒

Depends if it's a multi-core system. If you have four cores available, for example, then using four threads should see an approximate four times speed-up in processing (assuming no inter-dependencies between threads).

2018年09月25日41分52秒