how to send a reference/addressof some procedure to a new thread?

  • Thread starter Thread starter buu
  • Start date Start date
B

buu

So, I have a new thread creating something like:

dim myThread as new System.Threading.Thread(AddressOf myProcedure)


but, could I send an any kind of parameter instead of call to myProcedure???
I don't know did I made myself clear, but I would like to have something
like:


public sub StartThread(byref myProc as Object)
dim myThread as new System.Threading.Thread(AddressOf myProc)
mythread.Start
end sub
 
So, I have a new thread creating something like:

dim myThread as new System.Threading.Thread(AddressOf myProcedure)

but, could I send an any kind of parameter instead of call to
myProcedure???
I don't know did I made myself clear, but I would like to have something
like:

public sub StartThread(byref myProc as Object)
dim myThread as new System.Threading.Thread(AddressOf myProc)
mythread.Start
end sub

Well, that really depends on what you're actually passing. For sure, you
don't need the "byref". You also wouldn't need the "AddressOf" in the
constructor for the Thread instance either. However, you _would_ need the
"AddressOf" wherever it is you are actually getting a method address to
pass, and the type of the parameter either needs to be a proper delegate
type, or you'll need to cast it when you create the Thread (and of course
it has to be a valid cast).

But yes, assuming you comply with all of that, you need not resolve the
address when you're creating the Thread instance. It can be resolved
earlier and then passed as a parameter to some method that uses it to
create a Thread instance.

If that's not what you're asking, then you will need to clarify your
question.

Pete
 
Back
Top