Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Important
XBOX Docs are now on docs.xbox.com! This page is kept as an archive and is no longer being updated. Visit our documentation on docs.xbox.com for the latest information and updates.
This topic provides an example of how to set up async tasks. Set up an XAsyncBlock for the async task that will run. These async blocks can't be shared between multiple active async tasks. However, they can be reused for a different task after the original task is finished. A simple pattern is to just dynamically allocate the block for each call, and then release it when the call is finished in the completion callback.
XAsyncBlock* async = new XAsyncBlock{};
async->queue = taskQueue;
async->context = contextData;
async->callback =
[](XAsyncBlock* async)
{
// The optional completion callback.
delete async;
}
The parameter for the completion callback is the async block that was previously created. This allows for the context to be accessed and cast to the proper type for usage as both input and output, if you want to do so.
Reference API documentation
- XAsync (API contents)
- Structures