G
Guest
Hello,
We have a vb.net dll which secuentially calls a method which inserts a record in our database.
Our user fills up a grid with 15 records, we create an in memory xml which is passed to business tier. The business tier iterates through this xml calling a method in another dll which verifies some info and the inserts the record in the database.
The overall process takes around 40 seconds. We are trying to implement a solution which uses multitheading to execute the inserts in multiple threads. This way we think we can gain some tieme in the overall solution.
We would really appreciate if somebody could give us a link or example to accomplish this.
Here is our example of what we are trying to accomplish:
BEGIN CODE:
Public Class clsThread
Public myThread As System.Threading.Thread
Public myvalue As String
Sub startMultiThreadInsert(ByVal array As String())
Dim i As Integer
For i = 0 To array.Length - 1
myvalue = array(i).ToString
myThread = New System.Threading.Thread(AddressOf Insert)
Next
End Sub
Sub Insert()
clsBusiness.Insert(myvalue)
End Sub
END CODE:
We are not really sure if this is the best approach to do it , or if there is another way.
- AddressOff doesn´t accept parameters, we are using a global varaiable as a container for the value.
- I think we have a synch problem with the variable myvalue.
- We also would need some sort of notification when the threads are done doing the inserts, so we can know when everything has finished.
Many Thanks,
SAM
We have a vb.net dll which secuentially calls a method which inserts a record in our database.
Our user fills up a grid with 15 records, we create an in memory xml which is passed to business tier. The business tier iterates through this xml calling a method in another dll which verifies some info and the inserts the record in the database.
The overall process takes around 40 seconds. We are trying to implement a solution which uses multitheading to execute the inserts in multiple threads. This way we think we can gain some tieme in the overall solution.
We would really appreciate if somebody could give us a link or example to accomplish this.
Here is our example of what we are trying to accomplish:
BEGIN CODE:
Public Class clsThread
Public myThread As System.Threading.Thread
Public myvalue As String
Sub startMultiThreadInsert(ByVal array As String())
Dim i As Integer
For i = 0 To array.Length - 1
myvalue = array(i).ToString
myThread = New System.Threading.Thread(AddressOf Insert)
Next
End Sub
Sub Insert()
clsBusiness.Insert(myvalue)
End Sub
END CODE:
We are not really sure if this is the best approach to do it , or if there is another way.
- AddressOff doesn´t accept parameters, we are using a global varaiable as a container for the value.
- I think we have a synch problem with the variable myvalue.
- We also would need some sort of notification when the threads are done doing the inserts, so we can know when everything has finished.
Many Thanks,
SAM