Bonjour @Tous

Dans mon aventure avec les threads je rencontre un nouveau pb,
Quand je fais un Abort sur un thread en cours, il me leve bien l'exception ThreadAbortException mais ca bloque...a priori c'est mon RaiseEvent qui l'emerde. Pourquoi ?

Lancement du thread
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
    Public Sub Exporter()
        If Exporting Then
            Return
        End If
 
        _Durée = System.Environment.TickCount
        _Exporting = True
        _ExportThread = New Thread(New ThreadStart(AddressOf ThreadProcedure))
        _ExportThread.IsBackground = True
        _ExportThread.Start()
    End Sub
Procedure du thread
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
18
19
20
21
    Private Sub ThreadProcedure()
        _Erreur = Nothing
 
        Try
            RaiseEvent DébutExport(Me, New DébutExportEventArgs(_Chemin))
            _ugeXLS.Export(_Grid, _Chemin)
            _Statut = Enums.StatutExport.Succès
 
        Catch ex As Exception
            _Erreur = ex.Message
            _Statut = Enums.StatutExport.Echec
 
        Finally
            _Exporting = False
            _Durée = System.Environment.TickCount - _Durée
            RaiseEvent FinExport(Me, New FinExportEventArgs(_Statut, _Durée, _Chemin, _Ouvrir, _Erreur))
 
 
        End Try
 
    End Sub
Arret du thread
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    Public Sub ArreterExport()
        If Not _Exporting Then
            Return
        End If
 
        If _ExportThread.IsAlive Then
            _ExportThread.Abort()
            _ExportThread.Join()
        End If
 
        _Statut = Enums.StatutExport.Annulation
        _ExportThread = Nothing
        _Exporting = False
    End Sub