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. passing more than 1 parameter in thread

passing more than 1 parameter in thread

Scheduled Pinned Locked Moved Visual Basic
csharptutorial
2 Posts 2 Posters 0 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.
  • _ Offline
    _ Offline
    _tasleem
    wrote on last edited by
    #1

    hi,i have made an application in C# and vb.net,it working fine in C#, now when converting for C# to vb.net there is situation in which i have to call thread with 2 parameters, in C# i have used anyomous method here is code of that ThreadStart st = delegate { ParseURL(strURL, this); }; Thread th = new Thread(new ThreadStart(st)); th.Start(); i am trying to convert that code in vb.net but it did not work dim st as ThreadStart = delegate( ParseURL(strURL, Me)) Dim th As New Thread(New ThreadStart(AddressOf ParseURL)) th.start() then i used but i accept only one parameter not 2 parameters. Dim th As New Thread(New ParameterizedThreadStart(AddressOf ParseURL)) th.IsBackground = True th.Start(strURL) plz tell me how to pass 2 parameters to thread in vb.net

    Regards. Tasleem Arif

    G 1 Reply Last reply
    0
    • _ _tasleem

      hi,i have made an application in C# and vb.net,it working fine in C#, now when converting for C# to vb.net there is situation in which i have to call thread with 2 parameters, in C# i have used anyomous method here is code of that ThreadStart st = delegate { ParseURL(strURL, this); }; Thread th = new Thread(new ThreadStart(st)); th.Start(); i am trying to convert that code in vb.net but it did not work dim st as ThreadStart = delegate( ParseURL(strURL, Me)) Dim th As New Thread(New ThreadStart(AddressOf ParseURL)) th.start() then i used but i accept only one parameter not 2 parameters. Dim th As New Thread(New ParameterizedThreadStart(AddressOf ParseURL)) th.IsBackground = True th.Start(strURL) plz tell me how to pass 2 parameters to thread in vb.net

      Regards. Tasleem Arif

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The C# code actually doesn't send any argument at all when starting the thread. The values are put in the delegate object instead. As anonymous methods are not available in VB.NET, you can't use this trick, so you have to use a different one. Create a class that has two member variables and a method (or add them to an existing class). Create an instance of the class and put the values in the variables and use the method to start the thread. That way the method has access to the values.

      Experience is the sum of all the mistakes you have done.

      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