Hello,
With asynchronous programming :
Why does the callback-function (running in a worker thread) may not update
the state of a control on the main-form ?
The docs say that you must use a MethodInvoker instead as in following
example :
Private Sub CallBtn_Click(B yVal sender ...) Handles CallBtn.Click
webServiceObj = New MyDatabaseWSCla ss()|
Dim delCB As New AsyncCallback(A ddressOf MyCallBack)
aResult = webServiceObj.B eginConnectToDB (CInt(txtSecond s.Text), delCB,
Now)
End Sub
Private Sub UpdateUI()
OutputLabel.Tex t = "Async: Web service call complete."
End If
Private Sub MyCallBack(ByVa l result As IAsyncResult)
If webServiceObj.E ndConnectToDB(r esult) = True Then
DisplayMessage( result)
End If
' following is NOT allowed although it works fine ?????
OutputLabel.Tex t = "Async: Web service call complete."
Dim mi As New MethodInvoker(A ddressOf Me.UpdateUI)
Me.BeginInvoke( mi)
End Sub
Any ideas ?
Thank you
Chris