troubleshooting Question

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

Avatar of LeighWardle
LeighWardleFlag for Australia asked on
.NET ProgrammingVisual Basic.NET
3 Comments1 Solution15 ViewsLast Modified:

Hi Experts,

I am trying to get a Timer to work in my 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

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



Freelance programmer / Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros