Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

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

Reply
 
Old 03-08-2008   #1 (permalink)
buu


 
 

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

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



My System SpecsSystem Spec
Old 03-08-2008   #2 (permalink)
Stephany Young


 
 

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

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@xxxxxx> wrote in message news:fqtnmq0bah@xxxxxx
Quote:

> 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
>
My System SpecsSystem Spec
Old 03-08-2008   #3 (permalink)
buu


 
 

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

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


"Stephany Young" <noone@xxxxxx> wrote in message
news:O638CdQgIHA.3352@xxxxxx
Quote:

> 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@xxxxxx> wrote in message news:fqtnmq0bah@xxxxxx
Quote:

>> 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
>>
>

My System SpecsSystem Spec
Old 03-08-2008   #4 (permalink)
Stephany Young


 
 

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

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@xxxxxx> wrote in message news:fqv5h40f0@xxxxxx
Quote:

>I tried, but it's not working..
> I got an error: "AddressOf operand must be the name of method (withoud
> parenthesses).
>
>
> "Stephany Young" <noone@xxxxxx> wrote in message
> news:O638CdQgIHA.3352@xxxxxx
Quote:

>> 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@xxxxxx> wrote in message news:fqtnmq0bah@xxxxxx
Quote:

>>> 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
>>>
>>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How do the current thread get thread notification of OS intruption .NET General
Start a new thread from an existing thread, which was started from atimer .NET General
AddressOf .. whats the Powershell equivalent ? PowerShell
cannot reply or send a thread Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46