VB.NET 4.0: Looking to execute multiple threads, but wait until all threads are completed before resuming

前端 未结 1 1255
北荒
北荒 2021-01-16 06:13

I just had a new, last-minute idea on to take on a task, so I am running to StackExchange for quick help.

What I want to do is execute a series of methods right in a

相关标签:
1条回答
  • 2021-01-16 06:35

    If you're using .NET 4, it would be best to use the Task Parallel Library.

    The simplest approach in this case sounds like Parallel.Invoke which will invoke each of a collection of Action delegates using an appropriate degree of parallelism, and waiting until they've all completed before returning.

    If you need more fine-grained control than that, you can start each as a separate Task and use Task.WaitAll to wait for everything to finish.

    0 讨论(0)
提交回复
热议问题