473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Async Delegate

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
Jan 9 '06 #1
3 1295
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:83**********************************@microsof t.com...
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

Jan 10 '06 #2
>> 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==]
"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:us**************@TK2MSFTNGP10.phx.gbl... "iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:83**********************************@microsof t.com...
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

Jan 12 '06 #3
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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... :)


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

-cd
Jan 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Dave | last post by:
I'm using the BeginInvoke method of a delegate to invoke a thread asynchronously and then use the EndInvoke to retrieve the value. This works wonderfully until a Serviced Component is added to...
39
by: jabailo | last post by:
I am looping through a text file, and with each row, I launch a web service, asynchronously. Before I move on to the next step in the process, I want to make sure that all the web services have...
4
by: Brett Robichaud | last post by:
I'm using an async delegate to spawn a thread and run some code. I also specify an AsyncCallback to get notified when the thread completes. The problem is that my callback is being called twice...
10
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting...
11
by: ryan | last post by:
Hi, I've omitted a large chunk of the code for clarity but the loop below is how I'm calling a delegate function asynchronously. After I start the each call I'm incrementing a counter and then...
7
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets...
9
by: BartMan | last post by:
Greetings, I am trying to fire aysnc events in c++/clr, and I can't seem to get it to work. It seems to work fine in c#, but when I try c++/clr, I can't seem to get it to compile in the c++/clr...
12
by: =?Utf-8?B?cGI=?= | last post by:
I am having trouble doing a redirect in an async asp.net implemention. Most of the time it works, but when it doesn't it just "hangs", the browser never gets any return page. If I run it under the...
2
by: jojoba | last post by:
Hello to all! I have a fairly simple webservice running in asp.net ajax under c# (vs 2008). I built the service and it runs just dandy when i test it by itself in visual studio. However, to...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.