login about faq

Language: Visual C++ 10.0 (32-bit)

If I open a socket and start a task with AcceptNextConnectionAsync, the event TaskCompleted is not called. The alternative with a get_Finished() while loop works. Is there an error in my usage?

class INetSocketConnectionProgress : public CkBaseProgress
INetSocketConnectionProgress () { }

void INetSocketConnectionProgress::TaskCompleted (CkTask& task)
//do something

void listen ()
CkSocket* socket = new CkSocket ();
socket->BindAndListen (0, 5);

INetSocketConnectionProgress progress;
socket->put_EventCallbackObject (&progress);

CkTask* acceptTask = socket->AcceptNextConnectionAsync (0);
acceptTask->Run ();

This is only an extract from the sourcecode. The function listen() is called by another part.
If I cancel the task, in the debug log of the task it says: "currentTaskStatus: TASK_STATUS_COMPLETED".

Many thanks for a hint in the right direction.

asked Mar 14 '17 at 18:52

serras's gravatar image


Your progress object is local and on the stack.

Your "listen()" method starts the async accept task and returns immediately. Upon returning the progress object (on the stack) is destructed.

The callback never happens because the callback object is no longer in existence.


answered Mar 23 '17 at 22:18

chilkat's gravatar image

chilkat ♦♦

Many thanks for your hint. I dont know, why I dont saw it.

(Apr 06 '17 at 10:00) serras
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Mar 14 '17 at 18:52

Seen: 1,568 times

Last updated: Apr 06 '17 at 10:00

powered by OSQA