[VB.NET] Contôles créés sur un autre thread
Bonjour,
j'ai un souci avec l'execution asynchrone d'un WebService qui me retourne un DataSet.
Voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Private Sub ChargeDGMessages()
Try
'Appel du webservice
Dim ascb As AsyncCallback = New AsyncCallback(AddressOf threadCharge)
WS.BeginMessageMontre(ascb, WS)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
'Thread de ws asynchrone
Private Sub threadCharge(ByVal Reponse As IAsyncResult)
Try
Dim WS As WsPosition.InfoPosition = CType(Reponse.AsyncState, WsPosition.InfoPosition)
dgMessages.DataSource = WS.EndMessageMontre(Reponse)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub |
Et c'est la ligne où j'assigne le DataSet au DataGrid que j'obtiens ce message :http://toniolol.free.fr/Tempo_Img/WS2_petit.jpg
Comment puis-je faire, autrement que dans un timer pour binder mon DataGrig ?