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

# XAsyncSchedule

> 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\*](/reference/system/xasync/structs/xasyncblock)

A pointer to the [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) that was passed to [XAsyncBegin](/reference/system/xasyncprovider/functions/xasyncbegin) 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](/reference/errorcodes).

## 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](/reference/system/xasyncprovider/functions/xasyncschedule) 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](/build/core-features/common/async/async-programming-model#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](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider)
* [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)

## See also

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


## Related topics

- [XAsyncProvider](/reference/system/xasyncprovider/xasyncprovider_members.md)
- [XAsyncOp](/reference/system/xasyncprovider/enums/xasyncop.md)
- [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model.md)
- [XAsyncRun](/reference/system/xasync/functions/xasyncrun.md)
- [XAsyncBegin](/reference/system/xasyncprovider/functions/xasyncbegin.md)
