login about faq

ChilkatVersion: 9.5.0.65
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
{
public:
INetSocketConnectionProgress () { }
CK_BASEPROGRESS_API
};

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 at 18:52

serras's gravatar image

serras
666612


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.

link

answered Mar 23 at 22:18

chilkat's gravatar image

chilkat ♦♦
12.8k317367483

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

(Apr 06 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

By RSS:

Answers

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

Tags:

×15
×12

Asked: Mar 14 at 18:52

Seen: 472 times

Last updated: Apr 06 at 10:00

powered by OSQA