我努力让这个工作起来并且没有运气。如何获得并行扩展来运行具有两个输入参数的函数?我正在使用更新版本,3.5框架的Reactive Extensions。
我需要获取扩展程序才能运行行为(或函数 ProcessOrder ),但无论我尝试什么,我都无法做到这一点。
Dim act As New System.Action(Of Int32, Date)(AddressOf ProcessOrder)
act(CInt(RowA("ID")), RunDate)
Tasks.Task.Factory.StartNew(act)
我曾经能够做到以下几点:
Dim A(0) As Object
A(0) = CInt(RowA("ID"))
A(1) = RunDate
Tasks.Task.Create(AddressOf ProcessOrder, A)
但它不再受支持了
答案 0 :(得分:1)
创建一个小类,它将两个参数作为属性,并在类上有一个对这些属性起作用的方法。
Public Class ProcessClass
Private _p1 As Integer
Private _p2 As Date
Public Sub New(ByVal p1 As Integer, ByVal p2 As Date)
Me._p1 = p1
Me._p2 = p2
End Sub
Public Sub ProcessOrder()
Trace.WriteLine(String.Format("{0}:{1}", _p1, _p2))
End Sub
End Class
然后通过以下方式调用它:
Dim Obj As New ProcessClass(1, DateTime.Now())
Dim Act As New System.Action(AddressOf Obj.ProcessOrder)
System.Threading.Tasks.Task.Factory.StartNew(Act)