testing if Form is active
I have a thread timer that works and calls a sub below, what I want the sub to do is refresh the form for the user. The issue I have is if the form isn't in focus (say the screensaver kicked on or you bring up another program or something) then the code crashes.
When the timer expires it calls this sub
Shared Sub CheckStatus(ByVal State As Object)
Dim myform As Form
myform = frmMain.ActiveForm
'MessageBox.Show("I am refreshed")
myform = Nothing
the problem is if frmMain is not the active form (because of screen saver or whatever) then myform doesn't get set and crashes when it tries to refresh it.
My question is how can I test if frmMain is active and if it is refresh it if not go on doing whatever?
Well, i'm a C# person, but just do a try and catch. If it fails, you know it's not active.
That worked so it wouldn't crash but is there a more elegant way to handle if the form is active?
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL