Windows Vista Forums

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


    buu Guest

    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

  2. #2


    Stephany Young Guest

    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

    > 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

  3. #3


    buu Guest

    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

    > 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

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

  4. #4


    Stephany Young Guest

    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

    >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

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

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do the current thread get thread notification of OS intruption Alexander Wykel .NET General 0 10 Jul 2009
Start a new thread from an existing thread, which was started from atimer Curious .NET General 1 13 Jun 2008
vs2008 Add Service Reference generates Reference.cs which wont com BillInPA Indigo 3 14 Jan 2008
AddressOf .. whats the Powershell equivalent ? dm_14 PowerShell 2 11 Jun 2007
cannot reply or send a thread kim dromgoole Vista mail 1 22 May 2007