Results 1 to 5 of 5

Thread: closing off my windows threads

  1. #1

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539

    closing off my windows threads

    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:
    1. Dim myThreadDelegate As New ThreadStart(AddressOf CheckStatusThreaded)
    2.     Public myThread As New Thread(myThreadDelegate)
    3.  
    4. Private Sub DefaultLoad()
    5. 'this populate a list box from the database
    6. end sub
    7.  
    8. 'my onload event
    9. Private Sub MonitoringCtl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    10.         DefaultLoad()
    11.  
    12.         CheckStatus() 'check status is a socket function which goes off to each server and checks stuff
    13.     End Sub
    14.  
    15. Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    16. 'my timer is enabled from start and its set to click at 15 seconds
    17.         CheckStatus()
    18.     End Sub
    19.  
    20. Private Sub CheckStatus()
    21. 'this is my sub so i can check the status of the socket app within the onload event and a timed event
    22.  
    23.         Try
    24.  
    25.             myThread.Start()
    26.            
    27.         Catch ex As Exception
    28.             MsgBox("CheckStatus" & ex.ToString)
    29.         End Try
    30.  
    31.     End Sub
    32.  
    33. Private Sub CheckStatusThreaded()
    34. 'this is just my process for the job in hand
    35. 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
    I am curretly building a defect management system for software and web developers,
    If you wana try it out (beta test) and keep it for free just send me a message

  2. #2
    Member
    Join Date
    Jan 2005
    Location
    in the nederlands
    Posts
    37

    Red face Re: closing off my windows threads

    have you add you file name of the data base a oledataconnection ?
    ot sql ect.
    what is xml ???

    help my please on this link for xml
    http://www.vbforums.com/showthread.php?t=322815



  3. #3

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539

    Re: closing off my windows threads

    sql but i cant see what that would have to do with it ?
    I am curretly building a defect management system for software and web developers,
    If you wana try it out (beta test) and keep it for free just send me a message

  4. #4
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: closing off my windows threads

    Thread.Abort
    Calling this method usually terminates the thread.


    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  5. #5

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539

    Re: closing off my windows threads

    that just gives an error message thread is not running it can not restart
    I am curretly building a defect management system for software and web developers,
    If you wana try it out (beta test) and keep it for free just send me a message

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width