I am having dataset with 5000 records. I am reading them in the below 2 functions and writing to excel.
FillDataRows1(worksheet)
FillDataRows2(worksheet)
private sub FillDataRow1(byval ws as worksheet)
Dim rowpointer As Integer = 0
While rowpointer <= dsCostUsage.Tables(0).Rows.Count - 1
While colpointer <= dsCostUsage.Tables(0).Columns.Count - 1
str = dsCostUsage.Tables(0).Rows(rowpointer)(colpointer).ToString()
DirectCast(ws.Cells(row, column), Range).Value2 = item
colpointer += 1
End While
End While
End sub
private sub FillDataRow2(byval ws as worksheet)
Dim rowpointer As Integer = 1001
While rowpointer <= dsCostUsage.Tables(0).Rows.Count - 1
While colpointer <= dsCostUsage.Tables(0).Columns.Count - 1
str = dsCostUsage.Tables(0).Rows(rowpointer)(colpointer).ToString()
DirectCast(ws.Cells(row, column), Range).Value2 = item
colpointer += 1
End While
End While
End sub
I am reading 1000 records in the first function and remaining in the second function.
The problem is it is taking minimum 4 min to complete this process.
So, I decided ro use THREADING as
Dim t As New Thread(AddressOf FillDataRows1)
Dim t1 As New Thread(AddressOf FillDataRows2)
t.Start(worksheet)
t1.Start(worksheet)
t.Join()
t1.Join()
When I create thread also it is taking same time .
Am i doing anything wrong in creation of thread? Is there any other way to improve the performance.