0

我有以下代码读取多个 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))

有人有更好的主意吗?

4

0 回答 0