开发者

thread is throwing HRESULT 800ac472 error

I am creting a thread and reading the dataset and writing the records into excel. But the thread is not reading complete records and breaks in the middle after reading 25 records.

        If dsCostUsage.Tables(0).Rows.Count > 150 Then
            Dim t As New Thread(AddressOf FillDataRows1)
            t.Start(worksheet)
        End If


Private Sub FillDataRows1(ByVal ws As Worksheet)

    Dim startuprow As Integer = 7
    Dim colpointer As Integer = 0
    Dim rowpointer As Integer = 0
    Dim str As String
        While rowpointer <= dsCostUsage.Tables(0).Rows.Count - 1
            While colpointe开发者_运维技巧r <= dsCostUsage.Tables(0).Columns.Count - 1
                str = dsCostUsage.Tables(0).Rows(rowpointer)(colpointer).ToString()
                DirectCast(ws.Cells(startuprow, colpointer + 1), Range).Value2 = item
                colpointer += 1
            End While
            colpointer = 0
            rowpointer += 1
            startuprow += 1
        End While

    End sub

Dont know the exact reason whhy it breaks in the middle. Is there anyway that we need to increase the time or anhything else is there?

I think before worker thread completes writing, the main thread completes and interrupt the worker thread to not to continue.


You could try calling t.Join()

That should make the main thread wait until the other(s) finish.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜