我的代码如下
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) { }
Visual Basic捕获cmd的输出
windows从多图标文件中select错误的图标,并自我渲染以更正大小
分布式键/值存储可以在windows上运行,并具有.Net客户端?
如果我对windows服务进行了更改,是否必须运行installutil.exe?
InvisibleOperationException隐藏窗口时
从本地C调用.NET托pipe代码
Python脚本输出使用C#redirect
login/模仿作为本地/域名用户从他们作为pipe理员启动的应用程序
当应用程序是服务时,SetWinEventHookcallback不起作用
如何强制Dns.GetHostAddresses .NET方法只查询DNS或DNScaching?
请检查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 Dominik
在你的情况下,如果你使用它更容易
Parallel.ForEach
在你的字符串列表而不是使用
Parallel.Invoke
附加参数。 让我知道如果你想坚持Parallel.Invoke。
Parallel.Invoke在你的代码传递一个Action<string>数组的时候接受Action数组。 你可以做的是:
public voID DownloadConcurrent(Action<string> Methord) { Action<string>[] methordList = new Action<string>[Concurent_Downloads]; var r = methordList.Select(a => (Action)(() => a("some_str"))).ToArray(); Parallel.Invoke(r); }
您需要用每个 *** 作的正确值替换some_str
总结以上是内存溢出为你收集整理的线程并行调用,动作全部内容,希望文章能够帮你解决线程并行调用,动作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)