Bonjour,

J'esssaie de stopper le backgroundworker


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 Private Sub ToolStripButtonNew_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ToolStripButtonNew.MouseDown
      backgroundWorker1.WorkerSupportsCancellation = True
        backgroundWorker1.CancelAsync()
    End Sub
 
 
 Private Sub Buttonvalid_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Buttonvalid.MouseClick
 backgroundWorker1.RunWorkerAsync()
end sub
 
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backgroundWorker1.DoWork
 
 If backgroundWorker1.CancellationPending Then
            e.Cancel = True
        End If
'do something 
end sub
le résultat si je clique sur le toolStripButtonNew et ensuite sur le boutonvalid
une exception à backgroundWorker1.RunWorkerAsync()
backgroundWorker1 n'est pas libre

merci