C
Chris
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(ByVal sender ...) Handles CallBtn.Click
webServiceObj = New MyDatabaseWSClass()|
Dim delCB As New AsyncCallback(AddressOf MyCallBack)
aResult = webServiceObj.BeginConnectToDB(CInt(txtSeconds.Text), delCB,
Now)
End Sub
Private Sub UpdateUI()
OutputLabel.Text = "Async: Web service call complete."
End If
Private Sub MyCallBack(ByVal result As IAsyncResult)
If webServiceObj.EndConnectToDB(result) = True Then
DisplayMessage(result)
End If
' following is NOT allowed although it works fine ?????
OutputLabel.Text = "Async: Web service call complete."
Dim mi As New MethodInvoker(AddressOf Me.UpdateUI)
Me.BeginInvoke(mi)
End Sub
Any ideas ?
Thank you
Chris
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(ByVal sender ...) Handles CallBtn.Click
webServiceObj = New MyDatabaseWSClass()|
Dim delCB As New AsyncCallback(AddressOf MyCallBack)
aResult = webServiceObj.BeginConnectToDB(CInt(txtSeconds.Text), delCB,
Now)
End Sub
Private Sub UpdateUI()
OutputLabel.Text = "Async: Web service call complete."
End If
Private Sub MyCallBack(ByVal result As IAsyncResult)
If webServiceObj.EndConnectToDB(result) = True Then
DisplayMessage(result)
End If
' following is NOT allowed although it works fine ?????
OutputLabel.Text = "Async: Web service call complete."
Dim mi As New MethodInvoker(AddressOf Me.UpdateUI)
Me.BeginInvoke(mi)
End Sub
Any ideas ?
Thank you
Chris