我正在尝试从 Delegates 更改为 Parallel.ForEach
我看到下面的工作正常。
Imports System.Threading.Tasks
Sub Main()
Dim secs() As Integer = {2, 3, 1}
Parallel.ForEach(secs, AddressOf Method2)
End Sub
Sub Method2(ByVal i As Integer)
Console.WriteLine(i.ToString)
End Sub
但是,如果我的 Sub 需要多个变量怎么办?你能告诉我我应该怎么做下面的事情吗?
Imports System.Threading.Tasks
Sub Main()
Dim secs() As Integer = {2, 3, 1}
Dim Path as String = "Constant"
Parallel.ForEach(secs, Path, AddressOf Method2)
End Sub
Sub Method2(ByVal i As Integer, path as string )
Console.WriteLine(i.ToString, path)
End Sub
谢谢