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

Re: how to send a reference/addressof some procedure to a new thread? by Stephany

Stephany
Sat Mar 08 04:29:16 CST 2008

Yes, but you will need to read up on Delegates.

It would then work out something like:

Public Sub StartThread(ByVal myProc as Delegate)

Dim myThread As New Thread(myProc)

mythread.Start

End Sub>

and you would call it with something like:

StartThread(AddressOf Thread1)

StartThread(AddressOf Thread2)

...

Get the idea?

The same concept can be used to pass event handlers as parameters.


"buu" <aha@a.com> wrote in message news:fqtnmq0bah@enews2.newsguy.com...
> 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
>


Re: how to send a reference/addressof some procedure to a new thread? by buu

buu
Sat Mar 08 16:55:31 CST 2008

I tried, but it's not working..
I got an error: "AddressOf operand must be the name of method (withoud
parenthesses).


"Stephany Young" <noone@localhost> wrote in message
news:O638CdQgIHA.3352@TK2MSFTNGP04.phx.gbl...
> Yes, but you will need to read up on Delegates.
>
> It would then work out something like:
>
> Public Sub StartThread(ByVal myProc as Delegate)
>
> Dim myThread As New Thread(myProc)
>
> mythread.Start
>
> End Sub>
>
> and you would call it with something like:
>
> StartThread(AddressOf Thread1)
>
> StartThread(AddressOf Thread2)
>
> ...
>
> Get the idea?
>
> The same concept can be used to pass event handlers as parameters.
>
>
> "buu" <aha@a.com> wrote in message news:fqtnmq0bah@enews2.newsguy.com...
>> 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
>>
>



Re: how to send a reference/addressof some procedure to a new thread? by Stephany

Stephany
Sat Mar 08 18:46:22 CST 2008

I didn't say it is exactly like that, I said it is something like that.

You will need to read up on delegates to get the syntax correct.


"buu" <aha@a.com> wrote in message news:fqv5h40f0@enews2.newsguy.com...
>I tried, but it's not working..
> I got an error: "AddressOf operand must be the name of method (withoud
> parenthesses).
>
>
> "Stephany Young" <noone@localhost> wrote in message
> news:O638CdQgIHA.3352@TK2MSFTNGP04.phx.gbl...
>> Yes, but you will need to read up on Delegates.
>>
>> It would then work out something like:
>>
>> Public Sub StartThread(ByVal myProc as Delegate)
>>
>> Dim myThread As New Thread(myProc)
>>
>> mythread.Start
>>
>> End Sub>
>>
>> and you would call it with something like:
>>
>> StartThread(AddressOf Thread1)
>>
>> StartThread(AddressOf Thread2)
>>
>> ...
>>
>> Get the idea?
>>
>> The same concept can be used to pass event handlers as parameters.
>>
>>
>> "buu" <aha@a.com> wrote in message news:fqtnmq0bah@enews2.newsguy.com...
>>> 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
>>>
>>
>
>