G
Guest
Please consider the following thread setup intended to free-up the UI while a
huge process takes place:
(declare delegates) (A B and C all global)
Private Sub AB_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AB.Click
Dim NoArg1 As New NoArgs(AddressOf AxB)
NoArg1.BeginInvoke(Nothing, Nothing)
End Sub
Private Sub AxB()
Dim mult As New TwoArgs(AddressOf solver.Matrix_Multiply)
Dim AsyncResult As IAsyncResult = mult.BeginInvoke(A, B, Nothing,
Nothing)
Do Until AsyncResult.IsCompleted
For i = 1 To 1000000 : Next : Button3.Text = Rnd().ToString
Loop
C = mult.EndInvoke(AsyncResult)
do other stuff with C
End Sub
Matrix_Multiply is the class solver and consumes 50% of CPU resources with a
hyperthreading P4. It is floating point arithmatic intensive. When I run the
program the UI is unavailable until the final C result - which is double(,) -
is obtained. Button3.text initially shows activity but then stops. The
threading logic works fine with a local function that simply runs a loop then
returns a string.
What's wrong? How fix?
huge process takes place:
(declare delegates) (A B and C all global)
Private Sub AB_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AB.Click
Dim NoArg1 As New NoArgs(AddressOf AxB)
NoArg1.BeginInvoke(Nothing, Nothing)
End Sub
Private Sub AxB()
Dim mult As New TwoArgs(AddressOf solver.Matrix_Multiply)
Dim AsyncResult As IAsyncResult = mult.BeginInvoke(A, B, Nothing,
Nothing)
Do Until AsyncResult.IsCompleted
For i = 1 To 1000000 : Next : Button3.Text = Rnd().ToString
Loop
C = mult.EndInvoke(AsyncResult)
do other stuff with C
End Sub
Matrix_Multiply is the class solver and consumes 50% of CPU resources with a
hyperthreading P4. It is floating point arithmatic intensive. When I run the
program the UI is unavailable until the final C result - which is double(,) -
is obtained. Button3.text initially shows activity but then stops. The
threading logic works fine with a local function that simply runs a loop then
returns a string.
What's wrong? How fix?