Skip to main content
This topic provides an example of a generic async task wrapper. Instead of manually setting up async blocks and calling XAsyncRun for each task, create a RunTask wrapper to simplify this process. By using this wrapper, you can specific a task queue, a work, and an optional completion callback.
The previous sample implements a function that takes an async block and two callbacks: one work and one completion. You can write a version to just take a work callback, because the completion callback is optional. It uses the standard pattern to setup an async block, setup context data, and call XAsyncRun. RunTask encapsulates the boilerplate code, creating a simple standalone task function. Simple data capturing passes to the callbacks without context parameters by using std::function.

Reference API documentation

See also

Asynchronous programming overview XAsync XTaskQueue
Last modified on August 4, 2026