quand un bouton est cliqué je démarre un thead séparé qui est une grille de population et fait quelque chose avec un webbrowser-contrôle. Mais lorsque le bouton est cliqué, le nouveau thread ne semble pas être séparé, car l'interface utilisateur gèle jusqu'à ce que le nouveau thread soit terminé.Le nouveau thread bloque toujours l'UI-Thread
Voici le code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
FindCustomerLocation()
e.Handled = True
End Sub
Private Sub FindCustomerLocation()
Dim Findcontractor_Thread As New Thread(AddressOf FindContractor_ThreadExecute)
Findcontractor_Thread.Priority = ThreadPriority.AboveNormal
Findcontractor_Thread.Start()
End Sub
Delegate Sub FindContractorDelegate(ByVal igGrid As Infragistics.Windows.DataPresenter.XamDataGrid, ByVal webbrowser As Controls.WebBrowser)
Private Sub FindContractor_ThreadExecute()
Dim threadControls(1) As Object
threadControls(0) = Me.XamDataGrid1
threadControls(1) = Me.WebBrowserMap
Dim m As FindContractorDelegate = AddressOf FindContractor_WorkingThread
Me.Dispatcher.BeginInvoke(m, threadControls)
End Sub
Private Sub FindContractor_WorkingThread()
Mouse.OverrideCursor = Cursors.Wait
'Do something...
Mouse.OverrideCursor = Nothing
End Sub
Ce que je fais mal?
Merci, Neils
Dans mon thread séparé, je travaillais avec WinForms et le système fait jeter une exception de rapporter ce que vous dites. – Zac