Link to home
Start Free TrialLog in
Avatar of LeighWardle
LeighWardleFlag for Australia

asked on

VB.NET WinForms code - How to get code to wait until Timer is stopped?

Hi Experts,


I am trying to get a Timer to work in my vb.net code.

Here's my current code:


Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load         Timer1.Interval = 1000 '1 second         Timer1.Enabled = True         Timer1.Start()         MsgBox("Why can't this statement get executed after the Timer1 is stopped?")     End Sub     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick         MsgBox("hello from Timer1")     End Sub End Class

Open in new window

How can I prevent the msgbox statement (and any statements that follow it) from being executed until the Timer is Stopped?


Regards,

Leigh


ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What exactly do you want to do with the timer?
Avatar of LeighWardle

ASKER

Thanks, Andy.

Regards,
Leigh