Is there a .Net class to do what ManualResetEvent.PulseAll() would do (if it existed)?

前端 未结 2 1531
栀梦
栀梦 2021-02-14 23:00

Is there a .Net class to do what ManualResetEvent.PulseAll() would do (if it existed)?

I have a need to atomically release a set of threads that are waiting

2条回答
  •  孤街浪徒
    2021-02-15 00:02

    You can use a Barrier object. It allows an unspecified number of Tasks to run, then wait for all others to reach that point.

    And you can use it in a way similar to WaitGroup in Go if you do not know which tasks from which code blocks will start to work as a specific unit of work.

提交回复
热议问题