Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C相当于Objective-C';s调度组和队列?_C#_Objective C_Multithreading - Fatal编程技术网

C# C相当于Objective-C';s调度组和队列?

C# C相当于Objective-C';s调度组和队列?,c#,objective-c,multithreading,C#,Objective C,Multithreading,我正在将Objective-C应用程序移植到C#,我正在努力在C中实现以下功能# 我该怎么做呢?注意:这至少需要.NET Framework的4.5版 // create a new dispatch group List<Task> tasks = new List<Task>(); // iterate over a collection adding tasks to the dispatch group for (…) { Task task = Tas

我正在将Objective-C应用程序移植到C#,我正在努力在C中实现以下功能#


我该怎么做呢?

注意:这至少需要.NET Framework的4.5版

// create a new dispatch group
List<Task> tasks = new List<Task>();

// iterate over a collection adding tasks to the dispatch group
for (…) {
    Task task = Task.Run(() => {
        // do stuff
    });
    tasks.Add(task);
}

// wait for them all to finish
Task.WaitAll(tasks.ToArray());

// do more stuff that depends on them all finishing
//创建新的调度组
列表任务=新列表();
//迭代集合,将任务添加到调度组
对于(…){
任务=任务。运行(()=>{
//做事
});
任务。添加(任务);
}
//等待他们全部完成
Task.WaitAll(tasks.ToArray());
//做更多的事情,这取决于他们所有的完成

请参见C#。谢谢!正是我想要的
// create a new dispatch group
List<Task> tasks = new List<Task>();

// iterate over a collection adding tasks to the dispatch group
for (…) {
    Task task = Task.Run(() => {
        // do stuff
    });
    tasks.Add(task);
}

// wait for them all to finish
Task.WaitAll(tasks.ToArray());

// do more stuff that depends on them all finishing