Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

1. In my code i have a method called

VB
Method1(ByVal Number As String, ByVal ListNumber As String, ByVal created As String, ByVal Value As String, ByVal userId As Integer, ByVal CheckBox As Boolean) As DataTable


2. I am creating a thread
VB
Thread1 = New Threading.Thread(AddressOf Method1)
Thread1.Start()

here i am getting error, like Addressof should not contain a method which has parameters.
How to pass parameters to a thread.

we are using .net 1.1 framework. In this i can't implement ParameterizedThreadStart, Is there any other way to implement

TIA Subhash.
Posted
Updated 7-Aug-11 21:08pm
v5

This[^] should help you.
 
Share this answer
 
VB
NcplThread = New Threading.Thread(AddressOf ThreadWork)
Dim Parameters = new Object(){"1","1.1","User","value",1,True}
NcplThread.Start(Parameters)


Sub ThreadWork(Parameters as Object)
  SearchPickListSource(Parameters(0),Parameters(1),Parameters(2),Parameters(3),   Parameters(4),Parameters(5))
End Sub

Function SearchPickListSource(ByVal soNumber As String, ByVal PickListNumber As String, ByVal createdBy As String, ByVal sxValue As String, ByVal plantId As Integer, ByVal partnerCheckBox As Boolean) As DataTable
...
End Function
 
Share this answer
 
v2
Comments
subhash04573 25-Jul-11 5:19am    
The values are dynamic. That's the problem
Prerak Patel 25-Jul-11 5:30am    
Then you can pass variables
subhash04573 25-Jul-11 5:34am    
even on passing variables i am getting error
1.AddressOf ThreadWork does not have same signature as Delegate sub ThreadStart()
2.Too many arguments to Publis sub start()
subhash04573 25-Jul-11 6:28am    
we r using .net 1.1 framework. In this i can't implement ParameterizedThreadStart, Is there any other way to implement
Prerak Patel 25-Jul-11 6:35am    
http://netprogramminghelp.com/aspnet/how-to-create-a-parameterized-thread-in-aspnet11/
See the answers to this past question: Passing arguments to a threaded LongRunningProcess[^].

I suggested a thread wrapper which solves the problem of passing parameters, VSNetVbHarry implemented it for VB.NET. There is not need in parametrized thread start as you can pass an instance (non-static method) which passes "Self".

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900