Search code examples
vb.nettimerwindowfocus

Vb.NET Disabling timer when window loses focus


I'm developing a quiz software in vb. Net that has two separate windows after login. I've added timers to each of the windows. But the issue is how do I disable the timer count of one window when the mouse focus is on the other window??


Solution

  • As Hans suggested, use the form Deactivate event.

    Private Sub Form1_Deactivate(sender As Object, e As EventArgs) Handles MyBase.Deactivate
        ' deactivate this forms timer
    End Sub