我有这个子:
Private Sub error_out(ByVal line As Integer, ByVal err_col As Integer, ByVal err_msg As String)
Dim ln = t_erori.Rows.Add
ln.Item(0) = line
ln.Item(err_col) = err_msg
ln.Item(3) = err_col
End Sub
这是由运行在 parallel.for 循环中的几个函数调用的。
问题是有时(完全随机)我得到一个错误:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
上Dim ln = t_erori.Rows.Add
线。
我怀疑这是因为它试图两次添加同一行。我怎样才能使这项工作?或者我还能用什么方法来做到这一点?
我需要这个数据表,因为我的应用程序正在其中写入一些结果,但是任何其他存储与 parallel.for 一起使用的结果的方法都可以。