我的代码如下
public void DownloadConcurrent(Action<string> Methord)
{
Action<string>[] methordList = new Action<string>[Concurent_Downloads];
for (int i = 0; i < Concurent_Downloads; i++)
{
methordList[i] = Methord;
}
Parallel.Invoke(methordList);
}
Parallel.Invoke 出现错误:
"cannot convert from 'System.Action<string>[]' to 'System.Action[]'"
它调用的方法是
public void DownloadLinks(string Term)
{
}
最佳答案
像下面这样检查 Parallel.ForEach
static void Main(string[] args)
{
List<string> p = new List<string>() { "Test", "Test2", "Test3"};
Parallel.ForEach(p, Test);
}
public static void Test(string test)
{
Debug.WriteLine(test);
}
这应该对你有用
HTH 多米尼克
关于c# - 线程并行调用、操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6533401/