AddressOf with arguments
-
Hi When I use the "AddressOf" operand to call a procidure that requires some arguments, error occurs. How can I handle this problem. Error is "AddressOf operand must be the name of a method, no parentheses are required. Code snippet is below. Dim trThread As New Thread(AddressOf DoSomething(Arguments)) Sub DoSomething(Arguments) 'do something whatever it be End Sub Thanks reman
-
Hi When I use the "AddressOf" operand to call a procidure that requires some arguments, error occurs. How can I handle this problem. Error is "AddressOf operand must be the name of a method, no parentheses are required. Code snippet is below. Dim trThread As New Thread(AddressOf DoSomething(Arguments)) Sub DoSomething(Arguments) 'do something whatever it be End Sub Thanks reman
You can't do that. AddressOf returns exactly that, the address of a method. Your not actually calling the method, so passing parameters is pointless. Which version of VB.NET are you using??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Hi When I use the "AddressOf" operand to call a procidure that requires some arguments, error occurs. How can I handle this problem. Error is "AddressOf operand must be the name of a method, no parentheses are required. Code snippet is below. Dim trThread As New Thread(AddressOf DoSomething(Arguments)) Sub DoSomething(Arguments) 'do something whatever it be End Sub Thanks reman
On assumes you should just provide DoSomething and not worry about the arguments. You can only start a thread that takes no arguments, or a single argument, of type object, AFAIK.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
On assumes you should just provide DoSomething and not worry about the arguments. You can only start a thread that takes no arguments, or a single argument, of type object, AFAIK.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Christian Graus wrote:
or a single argument, of type object, AFAIK.
You are correct sir. Now, IIRC, that's only in .NET 2.0 and above. I think .NET 1.1- couldn't take any arguments at all and had to pick up any arguments from a third party object visible to the method being launched.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Christian Graus wrote:
or a single argument, of type object, AFAIK.
You are correct sir. Now, IIRC, that's only in .NET 2.0 and above. I think .NET 1.1- couldn't take any arguments at all and had to pick up any arguments from a third party object visible to the method being launched.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007No, I think I wrote .NET 1.1 code that multithreaded with a parameter.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
No, I think I wrote .NET 1.1 code that multithreaded with a parameter.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Really?? I haven't done any threading in quite a while. I've forgotten a bunch... I thought ThreadStart didn't take an argument, but the 2.0 ParameterizedThreadStart took an Object. Hmmm... where's my MSDN... :confused:
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007