标签云

微信群

扫码加入我们

WeChat QR Code


Do you need the results back in the same order?

2019年02月23日51分50秒

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

2019年02月22日51分50秒

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

2019年02月23日51分50秒

result.add must be thread safe yeah..

2019年02月23日51分50秒

Forgot to mention I need it in .NET 2.0

2019年02月22日51分50秒

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.

2019年02月22日51分50秒

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

2019年02月22日51分50秒

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

2019年02月22日51分50秒

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

2019年02月22日51分50秒

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

2019年02月22日51分50秒

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

2019年02月23日51分50秒

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

2019年02月22日51分50秒

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).

2019年02月22日51分50秒