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
| 'Dans la section déclaration
Delegate Sub TraitAsync(ByVal comp As Integer)
Dim Ta As New TraitAsync(AddressOf Traitement1)
Dim Iar As IAsyncResult
Sub Traitement1(ByVal Int As Integer)
Console.WriteLine("Passe ici ")
Dim Int1 As Integer = 0
Do Until Int1 = 10
Thread.Sleep(1000)
Console.WriteLine(Int1)
Int1 += 1
Loop
'Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Int2 += 1
If Int2 = 5 Then
Timer1.Stop()
Int2 = 0
Iar = Ta.BeginInvoke(5, AddressOf AffResult, Nothing)
Console.WriteLine("Ttttermine")
'Timer1.Start()
End If
Console.WriteLine("Thick")
'Button1.PerformClick()
End Sub
Sub AffResult(ByVal iar As IAsyncResult)
If iar.IsCompleted Then
Console.WriteLine("passe ici iar")
Timer1.Start()
End If
'Console.WriteLine(Ta.EndInvoke())
End Sub |
Partager