login about faq

I am using the Chilkat Socket asynchronous methods. To implement a progress Bar I tried using the event callback functions (in C++).

where myProgressObj is an instance of a class derived from CkBaseProgress. I am calling the AsyncReceiveBytesN method to read an amount of binary data, but no callback methods are being called. What's wrong?

asked Dec 22 '14 at 12:28

chilkat's gravatar image

chilkat ♦♦

There are no event callbacks for asynchronous methods. The definition of an event callback has to do with a single thread of execution. The thread of execution proceeds like this:

  1. Your app calls a (synchronous) Chilkat method. The thread of execution is now within the internals of the Chilkat method.
  2. An event callback is fired. This is a call back into your application's code (to the event callback handler method). The thread of execution is now within your app's code.
  3. Your app's callback handler returns. The thread of execution has returned back to the internals of the Chilkat method call.
  4. The Chilkat method call returns. The thread of execution has returned back to your app's code.

When an asynchronous method is called, Chilkat creates a background thread to run the task. The method that initiates the async task returns immediately to your application (in this case, AsyncReceiveBytesN returns and a separate background thread is doing the ReceiveBytesN). There cannot be a callback from the background thread to your app's foreground thread, because they are separate threads of execution. (Technically it's possible, but all sorts of problems can arise depending on the application's architecture, programming language, etc. where app code in a background thread is restricted especially when it comes to accessing UI elements.) The foreground thread of your application can choose to periodically check the current status of a background (async) task by examining whatever properties might be available for such a thing: such as by examining the socket.ReceivedCount property.


answered Dec 22 '14 at 12:40

chilkat's gravatar image

chilkat ♦♦

edited Dec 22 '14 at 12:45

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: Dec 22 '14 at 12:28

Seen: 2,542 times

Last updated: Dec 22 '14 at 12:45

powered by OSQA