VB Code:
Dim flagstopciclo As Boolean = False
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'AddHandler Application.Idle, AddressOf Me.Orologio
Me.Timer1.Enabled = True
End Sub
Private Sub Orologio(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Text = Now
End Sub
Private Sub BtnFine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFine.Click
Me.flagstopciclo = True
End Sub
Private Sub BtnParti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnParti.Click
Do While Not Me.flagstopciclo
Application.DoEvents()
Loop
MessageBox.Show("Finito")
Me.flagstopciclo = False
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Orologio(Nothing, Nothing)
End Sub