以下代码似乎在执行时冻结了我的线程,这违背了我想要添加的进度的目的。有什么我需要调整来消除这个吗?我的假设是它与我正在加载的数据中的剪切量有关,在这个特定的例子中,它超过150个字段(标题行和1个数据行)。
Private Sub BackgroundWorker1_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim file As String = "<<file>>"
Dim path As String = "<<path>>"
Dim ConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='<<source>>';Extended Properties='text';"
Dim SQL = "SELECT * FROM " & path & file
tbl = New DataTable
' USING will close and dispose of resources
Using cn As New OleDbConnection(ConStr),
cmd As New OleDbCommand(SQL, cn)
cn.Open()
Using da As New OleDbDataAdapter(cmd)
da.Fill(tbl)
End Using
End Using ' close and dispose
' FIND the sequence column for this session
For n = 0 To tbl.Columns.Count - 1
If tbl.Columns(n).ColumnName.ToLowerInvariant = "sequence" Then
SeqColIndex = n
Exit For
End If
Next
End Sub