devxlogo

Prevent Timer Re-Entry

Prevent Timer Re-Entry

When using a timer control, it is important to prevent re-entry.This occurs when the processing in the _Timer event takes long enough to still be executing when the next _Timer event fires. It is even possible for the execution of the second timer event to pass up that of the first. Depending on what the code does, re-entry can cause all sorts of hard-to-trace problems.

A simple solution is to disable the timer control during the timer event handler:

    Private Sub Timer1_Timer()      Timer1.Enabled = False      'rest of code goes here      Timer1.Enabled = True   End Sub

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist