我有以下代码读取多个CSV文件,然后使用线程将数据传递给类。我必须将CSV路径和字符串传递给函数(两者都必须是动态的)。
Dim MyThread1 As PassResourceDataToClassDelagate = AddressOf PassResourceDataToClass
Dim FileTypes() As String = {".HOURLY", ".INTERVAL", ".EDSOLUTION", ".MCECTRL", ".PNODE"}
Dim TextBoxValues() As String = {RTBMHourlyTextBox.Text, RTBMIntervalTextBox.Text, _
RTBMEDSolutionTextBox.Text, RTBMMCECTRLTextBox.Text, _
RTBMPNodeTextBox.Text}
For K As Integer = 0 To 4
MyThread1.BeginInvoke(DirectCast(ReadCSVFile(TextBoxValues(K)), Object()()), FileTypes(K), Nothing, Nothing)
Next
我正在尝试学习Parallel.ForEach来做同样的事情。搜索互联网让我(这不起作用):
Parallel.ForEach(TextBoxValues, FileTypes, Sub(ByRef TBName As String, ByRef FleType As String) _
PassResourceDataToClass(DirectCast(ReadCSVFile(TBName), _
Object()()), FleType))
有人有更好的主意吗?