I have a timer in my application (timer1). When this timer goes off, it calls a sub that refreshes my datagridview. Before calling the refresh sub, I use GetActiveWindow() from user32 Lib to check If the form is the active window. This works as expected. Here is the code I am using to check the active window.
If Me.Handle = GetActiveWindow() Then
gridRefresh()
Else
MessageBox.Show("Works")
End If
I included the messagebox just to give me a visual that It is indeed working when the active window is not my Application.
What I am missing though is I would like to call the gridRefresh() sub once my Application becomes the active window again.
My first thought would be to use a Do Until loop and have it do nothing until It becomes the active window again like so:
If Me.Handle = GetActiveWindow() Then
gridRefresh()
Else
Do Until Me.Handle = GetActiveWindow()
Loop
gridRefresh()
End If
But when I try this solution It never comes out of the loop.
Edit: The timer interval is 1 minute. The reason I want it to refresh once it becomes active again is so the user doesn't have to wait a whole minute to see if anything has been added to the gridview