> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XAsyncSchedule

> XAsyncSchedule

Schedules work for the callback function of an asynchronous provider.

## Syntax

```cpp theme={null}
HRESULT XAsyncSchedule(  
         XAsyncBlock* asyncBlock,  
         uint32_t delayInMs  
)  
```

### Parameters

*asyncBlock*   \_Inout\_\
Type: [XAsyncBlock\*](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md)

A pointer to the [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) that was passed to [XAsyncBegin](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasyncbegin.md) for the asynchronous call.

*delayInMs*   \_In\_\
Type: uint32\_t

How long the system should wait, in milliseconds, before scheduling the asynchronous call with the asynchronous queue.

### Return value

Type: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

Returns `S_OK` if successful; otherwise, returns an error code. For a list of error codes, see [Error Codes](https://docs.xbox.com/reference/errorcodes.md).

## Remarks

This function is optional, and provides more control over scheduling asynchronous work for an asynchronous provider. If the asynchronous work can be done through a system-managed asynchronous mechanism, such as [overlapped I/O](https://learn.microsoft.com/windows/win32/api/minwinbase/ns-minwinbase-overlapped?redirectedfrom=MSDN), you don't need to call this function.

If asynchronous work should be scheduled after a delay, specify in *delayInMs* the number of milliseconds that [XAsyncSchedule](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasyncschedule.md) should wait before it schedules asynchronous work.

For an example of an asynchronous provider that uses `XAsyncSchedule` to schedule asynchronous work, see the "Async Library" section in [Asynchronous Programming Model](https://docs.xbox.com/build/core-features/common/async/async-programming-model.md#heading-7).

## Requirements

**Header:** XAsyncProvider.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Set up custom provider](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider.md)
* [Asynchronous Programming Model](https://docs.xbox.com/build/core-features/common/async/async-programming-model.md)

## See also

[XAsyncProvider Members](https://docs.xbox.com/reference/system/xasyncprovider/xasyncprovider_members.md)\
[XAsyncBegin](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasyncbegin.md)\
[XAsyncSchedule](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasyncschedule.md)\
[Asynchronous Programming Model](https://docs.xbox.com/build/core-features/common/async/async-programming-model.md)


## Related topics

- [XAsyncOp](https://docs.xbox.com/reference/system/xasyncprovider/enums/xasyncop.md)
- [XAsyncProvider (API contents)](https://docs.xbox.com/reference/system/xasyncprovider/xasyncprovider_members.md)
- [Asynchronous Programming Model](https://docs.xbox.com/build/core-features/common/async/async-programming-model.md)
- [Set up custom provider](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider.md)
- [XAsyncRun](https://docs.xbox.com/reference/system/xasync/functions/xasyncrun.md)
