What Replaced Old Chilkat Async Methods?

In the distant past, there were some Chilkat classes that had a few ad-hoc Async methods and properties.  For example, the Ftp2 class contained the methods AsyncPutFileStart, AsyncGetFileStart, AsyncAppendFileStart, and properties such as AsyncFinished, AsyncSuccess, and AsyncLog.

A number of years ago, these were replaced with a consistent and standard async model that applies to any Chilkat method in any class such that the method has event callbacks.  For each method that can fire event callbacks (in programming languages that support event callbacks), there will be another method of the same name ending in “Async”.   For example, the async version of the method for Ftp2.PutFile is FtpPutFileAsync.

The async version of the method will have the same arguments as the non-async version.  For example, both Ftp2.PutFile and Ftp2.PutFileAsync have two string arguments: the local file path and the remote file path.  The async method returns a Chilkat Task object.

When your application calls the Async method, the information about the method name and arguments is embedded in the task object.  The application must then call Task.Run() to queue the task on Chilkat’s internal background thread pool.  The application is then free to do other things while the task is running.  The application can periodically check to see if the task has completed, failed, or was aborted.  After the task has completed, the value returned by the function (if it had been called synchronously) can be obtained by calling one of the following Task functions:  GetResultBool, GetResultString, GetResultInt, or GetResultBytes.  The function you would call depends on the return value type of the synchronous function.  For example, Ftp2.PutFile returns a boolean.  Therefore, after the PutFileAsync task completes, your application would call Task.GetResultBool to get the boolean return value.   If the synchronous function returns an object, there is another method for getting the returned object which is described in the examples on example-code.com under the “Async” category.

The general Async model is explained by examples in the “Async” category for each programming language on example-code.com.  Here’s a link to the Async category for VB6 on example-code.com:  https://www.example-code.com/vb6/async.asp

Also, be careful about combining Async methods with callbacks, because when a method is run asynchronously, Chilkat is effectively calling the synchronous method from a background thread.  Thus, when your application’s event handling code is called, it will be running in a background thread.

See:  https://www.chilkatforum.com/questions/10870/asynchronous-methods-in-vb6-be-very-careful-with-callbacks