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