A
Anthony Coelho
Hello Guru's!
I am trying to pass a function pointer as a parameter to a method and can't
seem to get it working. Basically I want to do the exact same thing that the
System.Threading.Thread constructor does in VB.NET within my own class. In
the Thread constructor, you can specify the function to run instead of
creating a ThreadStart object by using the AddressOf keyword such as; Dim
oThread As New Threading.Thread(AddressOf foo.Run)
I have a method that I would like to do the exact same thing as, but what do
you declare the type as? I've tried a delegate, but that's not working for
me. For example, say you have the following method:
Public foo(mydelegate as System.Delegate)
If you call this method passing a function pointer such as
myClass.foo(AddressOf myfunction.DoSomething) you get the following error:
'AddressOf' expression cannot be converted to 'System.Delegate' because
'System.Delegate' is not a delegate type.
How's that for a error? System.Delegate is not a delegate type? Are you as
confused on this as I am? So to wrap, does anyone know how I can pass a
function pointer into a method as a parameter just like the Threading.Thread
constructor allows?
Cheers,
Anthony
I am trying to pass a function pointer as a parameter to a method and can't
seem to get it working. Basically I want to do the exact same thing that the
System.Threading.Thread constructor does in VB.NET within my own class. In
the Thread constructor, you can specify the function to run instead of
creating a ThreadStart object by using the AddressOf keyword such as; Dim
oThread As New Threading.Thread(AddressOf foo.Run)
I have a method that I would like to do the exact same thing as, but what do
you declare the type as? I've tried a delegate, but that's not working for
me. For example, say you have the following method:
Public foo(mydelegate as System.Delegate)
If you call this method passing a function pointer such as
myClass.foo(AddressOf myfunction.DoSomething) you get the following error:
'AddressOf' expression cannot be converted to 'System.Delegate' because
'System.Delegate' is not a delegate type.
How's that for a error? System.Delegate is not a delegate type? Are you as
confused on this as I am? So to wrap, does anyone know how I can pass a
function pointer into a method as a parameter just like the Threading.Thread
constructor allows?
Cheers,
Anthony