Async Delegate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi, im trying to create a delagte for my async socket program but i cant
figure out how to create the async delegate for it. heres what i have so
far...

AsyncCallback * conasync = new AsyncCallback(0, this->ConnectCallBack);

heres my error:

x:\User\FinalProject\Battleship\NewGame.h(158): error C3351:
'System::AsyncCallback' : if you pass a NULL object instance to a delegate
constructor you must also pass the address of a static member function


it was very simple in VB but im seeing now its not quite as simple in
C++...if anyone can help me out thatd be great.

thanks
 
iwdu15 said:
hi, im trying to create a delagte for my async socket program but i cant
figure out how to create the async delegate for it. heres what i have so
far...

AsyncCallback * conasync = new AsyncCallback(0, this->ConnectCallBack);

new AsyncCallback(0, &YourClass::ConnectCallBack);

-cd
 
AsyncCallback * conasync = new AsyncCallback(0, this->ConnectCallBack);
new AsyncCallback(0, &YourClass::ConnectCallBack);

I would have thought it was this:

new AsyncCallback( this, ClassName::ConnectCallBack ) ;

but I'm now working in the new syntax, and my memory is weak... :)

[==P==]
 
Peter Oliphant said:
I would have thought it was this:

new AsyncCallback( this, ClassName::ConnectCallBack ) ;

but I'm now working in the new syntax, and my memory is weak... :)

It'd be 0 if the callback is static, or 'this' if it's not static.

-cd
 
Back
Top