I have four forms which is inherited from Baseform in another project .
In all four forms i am using a label to show some transaction count based on network status. i have implemented a thread which gets active form of application and settign up the text . Code works fine if application screen is active, if minimize and open any other application , i am getting an null error exception.
Please help me , how to get an active forms of an application.
Expand|Select|Wrap|Line Numbers
- Private Sub StartThread()
- pollThread =New Thread(AddressOf PollfileStatus)
- pollThread.IsBackground =True
- running =True
- pollThread.Start()
- End Sub
- Private Sub PollfileStatus()
- While (running)
- Try
- For Each e As Control In Me.ActiveForm.Controls
- If (e.Name = "pbStatus") Then
- e.Invoke(New SetTextCallback(AddressOf Settext), New Object() {e, 10})
- End If
- Next
- Catch ex As Exception
- Throw New ApplicationException(ex.Message)
- End Try
- Thread.Sleep(6000)
- End While
- End Sub