本文介绍了WaitHandle限制的解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行一些分析,很容易在多核机器上分解成许多独立的

件。


我以为它会是最好在

ThreadPool中排队1000个这样的部分,并让该对象负责在机器的自由周期中在后台运行它们。


但我需要程序等待所有排队的部分才能完成

继续。我尝试给每个工作项一个ManualResetEvent并使用

WaitHandler来检测它们何时完成,但事实证明

WaitHandle.WaitAll()赢了''需要超过64个WaitHandler。


当我们检测到进程的ThreadPool已经完成其

队列的正确方法是什么看看这个大小的队列?

I''m doing some analysis that is readily broken up into many independent
pieces, on a multicore machine.

I thought it would be best to just queue like 1000 of these pieces in the
ThreadPool, and let that object take care of running them in the background
on the machine''s free cycles.

But I need the program to wait for all the queued pieces to finish before it
continues. I tried giving each work item a ManualResetEvent and using
WaitHandler to detect when they''ve all finished, but it turns out that
WaitHandle.WaitAll() won''t take more than 64 WaitHandlers.

What is the right way to detect that a process''s ThreadPool has finished its
queue when we''re looking at queues of this size?

推荐答案




这篇关于WaitHandle限制的解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 19:35