Je patauge, a l´aide : Threads
Bonjour,
alors voila mon soucis :
Je tourne en rond depuis des heures pour pouvoir faire afficher un message a la fin de l´execution d´un thread (en l`occurence un thread qui travaille sur une base de donnee). une fois le boulot fini je veux afficher un message ds ma form
c´est vraiment pas gagne,je ne sais plus quoi faire a par n´importe quoi !
je vous poste le code que j´ai essaye :
Thread sur ma form (qui me permettra de gerer une barre de progression)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
Public Sub Thread()
_thread = New Thread(AddressOf StartThread)
_thread.Name = "main_thread"
Try
If (_thread.ThreadState = ThreadState.Unstarted) Then
_thread.Start() ' let's go
End If
Catch ex As Exception
LogFactory.getInstance().logInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, ex.Message.ToString())
End Try
End Sub
Private Sub StartThread()
Try
'2: Mailing Adressen in VIS
InfoBox.Items.Add("1 : Secure Mailing Adresse of VIS ...")
InfoBox.Items.Add("2 : Deleting Mailing Adresse in VIS ...")
key = CInt(objINI.Read("work", "MailingPart"))
If key = 1 Then
InfoBox.Items.Add("Already Done ...")
Else
db.FirstThread()
InfoBox.Items.Add("Done ...")
End If
Catch ex As Exception
LogFactory.getInstance().logInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, ex.Message.ToString())
End Try
End Sub |
puis le thread ds une classe qui bosse avec la bd
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Public Sub FirstThread()
_thread1 = New Thread(AddressOf StartThread)
_thread1.Name = "thread1"
Try
If (_thread1.ThreadState = ThreadState.Unstarted) Then
_thread1.Start() ' let's go
End If
Catch ex As Exception
LogFactory.getInstance().logInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, ex.Message.ToString())
End Try
End Sub
Private Sub StartThread()
Try
Secure_MailingAdresse()
Delete_MailingAdresse()
Catch ex As Exception
LogFactory.getInstance().logInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, ex.Message.ToString())
End Try
End Sub |
Merci de votre aide :)
Brice