hey all i have a slight problem i think i need to close off the thread or do something to it so it can be run on a timed basis and keep my UI alive
here is the code snippets, this is just lose snippets and not full code, its to help give you the idea of what i am trying to do
VB Code:
Dim myThreadDelegate As New ThreadStart(AddressOf CheckStatusThreaded) Public myThread As New Thread(myThreadDelegate) Private Sub DefaultLoad() 'this populate a list box from the database end sub 'my onload event Private Sub MonitoringCtl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load DefaultLoad() CheckStatus() 'check status is a socket function which goes off to each server and checks stuff End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'my timer is enabled from start and its set to click at 15 seconds CheckStatus() End Sub Private Sub CheckStatus() 'this is my sub so i can check the status of the socket app within the onload event and a timed event Try myThread.Start() Catch ex As Exception MsgBox("CheckStatus" & ex.ToString) End Try End Sub Private Sub CheckStatusThreaded() 'this is just my process for the job in hand end sub
so basically my application when loads gets data from the database and adds it to the list box these items are servers and application
i then use my socket code to check the status of the applications on the servers
the problem i get is an error message saying something like the thread is already running or has been stopped and can not be restarted
i wish for the listbox to check the status of the applications on load up and at a timed interval of 15 seconds this really does need to be threaded because the UI freezes every 15 seconds
How can i stop the thread and beable to reuse it ???
thanks in advance
Carl




Reply With Quote