[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

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

buu

3/9/2008 6:01:00 AM

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


1 Answer

Peter Duniho

3/9/2008 9:06:00 AM

0

On Sat, 08 Mar 2008 22:01:03 -0800, buu <aha@a.com> wrote:

> 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