Connecting Tech Pros Worldwide Help | Site Map

pass pointer to a thread function ?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 02:00 AM
mandatory
Guest
 
Posts: n/a
Default pass pointer to a thread function ?

hi,

i would like to pass a pointer to a thread function to a class.

The function in my code that i would like to get the address of, and pass it
to a class function is:

DWORD ServiceExecution(LPDWORD param)

And i would like to somehow send the address to a class function, similar to
this:

MyClass.ServiceExe (ServiceExecution):

Can this be done ? i have abit troubles getting it working - i remember that
i in the early years in normal C could do this fairly easy - but it has
really slipped my mind how the syntax is, and if its possible at all...

hope you can help !





  #2  
Old July 23rd, 2005, 02:00 AM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: pass pointer to a thread function ?

"mandatory" <okllsam@nptklooohs.ru> wrote...[color=blue]
> i would like to pass a pointer to a thread function to a class.
>
> The function in my code that i would like to get the address of, and pass
> it to a class function is:
>
> DWORD ServiceExecution(LPDWORD param)
>
> And i would like to somehow send the address to a class function, similar
> to this:
>
> MyClass.ServiceExe (ServiceExecution):
>
> Can this be done ?[/color]

Not if the class function is a non-static member. See the FAQ, section 33.
[color=blue]
> [..][/color]

V


  #3  
Old July 23rd, 2005, 02:00 AM
mandatory
Guest
 
Posts: n/a
Default Re: pass pointer to a thread function ?

"Victor Bazarov"[color=blue]
>
> Not if the class function is a non-static member. See the FAQ, section
> 33.
>[color=green]
>> [..][/color]
>
> V[/color]


hi victor !

thanks, but im not completely sure, but i think you might have misunderstood
me.

My goal isnt to start a memberfunction as a thread, im fully aware that this
has to be a static function outside the class (and then there are some ways
of make it "feel" its inside the class).

My goal is merely to pass on a address of a (static/global) function to a
class-member-function - like GetProcAddress() but just not from a library.


  #4  
Old July 23rd, 2005, 02:00 AM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: pass pointer to a thread function ?

"mandatory" <okllsam@nptklooohs.ru> wrote...[color=blue]
> "Victor Bazarov"[color=green]
>>
>> Not if the class function is a non-static member. See the FAQ, section
>> 33.
>>[color=darkred]
>>> [..][/color]
>>
>> V[/color]
>
>
> hi victor !
>
> thanks, but im not completely sure, but i think you might have
> misunderstood me.
>
> My goal isnt to start a memberfunction as a thread, im fully aware that
> this has to be a static function outside the class (and then there are
> some ways of make it "feel" its inside the class).
>
> My goal is merely to pass on a address of a (static/global) function to a
> class-member-function - like GetProcAddress() but just not from a library.[/color]

OK, I probably did misunderstand you. What problem do you have, then?

Your member function has to accept a pointer to a function as its argument
and when you pass it a function, it decays to a pointer to that function,
and everything is peachy.

If section 33 doesn't apply to your problem (which I admit is likely),
then you need to give FAQ 5.8 a try.

V


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.