c# - 线程并行调用、操作

标签 c# .net windows multithreading parallel-processing

我的代码如下

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/

相关文章:

windows - 64 位大型 malloc

C# Windows 服务和控制台应用程序合二为一

c# - 字符串中模式的正则表达式数据注释测试

.net - Android:从 .NET soap Web 服务检索 XML 结果

c# - 需要 .Net 的公式解释器

c# - 正则表达式替换大小写不敏感问题

.net - 如何将数据绑定(bind)到 System.Windows.Forms.Treeview 控件?

windows - 在 FOR 循环中使用什么定界符来读取行?

c# - 无法使用 XDocument 查询 XML 文档并获得所需的结果

c# - 函数返回范围 (a,b) 内呈指数分布的随机 double 值