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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#Dans un module
Public Structure My_Struct
Public id, sql, txt_progress As String
Public btn_to_active, result As Object
End Structure
#fin du module
#Dans mon Winform
Private Sub btn_test1_Click(...)..
dim my_stc As New My_Struct
btn_test2.enabled = false
With my_stc
.id = "toto"
.sql = "Select ... FROM ..."
.txt_progress= "do progress"
.btn_to_active = btn_test2
End With
bg_worker.RunWorkerAsync(my_stc)
End Sub
Private Sub btn_test2_Click(...)..
dim my_stc As New My_Struct
btn_test4.enabled = false
With my_stc
.id = "titi" 'RMARQUER LE CHANGEMENT DE ID
.sql = "Select ... FROM ..."
.txt_progress= "do progress"
.btn_to_active = btn_test1 ''changement
End With
bg_worker.RunWorkerAsync(my_stc)
End Sub
Private Sub bg_worker_DoWork(...) Handles bg_worker.DoWork
Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
Select Case e.Argument.id
Case "toto"
e.Result = do_traitement_toto(e.Argument, worker) ' return un type My_Struct
Case "titi"
e.Result = do_traitement_toto(e.Argument, worker) ' return unb type My_Struct
End Select
End Sub
Private Sub bg_worker_RunWorkerCompleted(...) Handles bg_worker.RunWorkerCompleted
Select Case e.Result.id
Case "toto"
messagebox.show("toto")
e.Result.btn_to_active.enabled = true
Case "titi"
messagebox.show("titi")
e.Result.btn_to_active.enabled = true
End Select
End Sub |
Partager