Flat C
auto asyncBlock = std::make_unique<XAsyncBlock>();
asyncBlock->queue = queue;
asyncBlock->context = nullptr;
asyncBlock->callback = [](XAsyncBlock* asyncBlock)
{
std::unique_ptr<XAsyncBlock> asyncBlockPtr{ asyncBlock }; // Take over ownership of XAsyncBlock*.
HRESULT hr = XAsyncGetStatus(asyncBlock, false);
};
HRESULT hr = XblTitleStorageDeleteBlobAsync(
xboxLiveContext,
blobMetadata,
deleteOnlyIfEtagMatches,
asyncBlock.get()
);
if (SUCCEEDED(hr))
{
// The call succeeded, so release the std::unique_ptr ownership
// of XAsyncBlock* because the callback now takes ownership.
// If the call fails, std::unique_ptr maintains ownership and deletes XAsyncBlock*.
asyncBlock.release();
}
