Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to restart a thread with new parameters

How to restart a thread with new parameters

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amer Rehman 0
    wrote on last edited by
    #1

    Hi, Can anyone tell me the solution to this problem. I have built a procidure wrapped in a class that takes a parameter.This procidure is called normally by starting a thread. When an event occures, it is required to call the procidure with new paramater. A code snippet would be like this. Private Sub btnReceive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReceive.Click remote = New RemoteConnection 'this is the class trListen1 = New Thread(AddressOf remote.ReceiveMessage) remote.msg = "Message has been received." trListen1.Start() End Sub Private Sub btnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChange.Click If trListen1.IsAlive = True Then trListen1.Abort() Else remote = New RemoteConnection trListen2 = New Thread(AddressOf remote.ReceiveMessage) remote.msg = "Message has been received,answer is here." trListen2.Start() End If End Sub But this does not work. How this can be handled? Thanks. reman

    J 1 Reply Last reply
    0
    • A Amer Rehman 0

      Hi, Can anyone tell me the solution to this problem. I have built a procidure wrapped in a class that takes a parameter.This procidure is called normally by starting a thread. When an event occures, it is required to call the procidure with new paramater. A code snippet would be like this. Private Sub btnReceive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReceive.Click remote = New RemoteConnection 'this is the class trListen1 = New Thread(AddressOf remote.ReceiveMessage) remote.msg = "Message has been received." trListen1.Start() End Sub Private Sub btnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChange.Click If trListen1.IsAlive = True Then trListen1.Abort() Else remote = New RemoteConnection trListen2 = New Thread(AddressOf remote.ReceiveMessage) remote.msg = "Message has been received,answer is here." trListen2.Start() End If End Sub But this does not work. How this can be handled? Thanks. reman

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      Hi Reman, What you are trying to do is reasonably clear, however...

      Amer Rehman wrote:

      But this does not work.

      is not. How does it not work? Is an error thrown, or what? If so, at what point in this code? etc? Johan

      My advice is free, and you may get what you paid for.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups