> ## 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.

# XDisplayAcquireTimeoutDeferral

> XDisplayAcquireTimeoutDeferral

# XDisplayAcquireTimeoutDeferral

获取屏幕超时延迟。

## Syntax

```cpp theme={null}
HRESULT XDisplayAcquireTimeoutDeferral(  
         XDisplayTimeoutDeferralHandle* handle  
)  
```

### Parameters

*handle*   \_Out\_\
类型：XDisplayTimeoutDeferralHandle\*

指向屏幕超时延迟句柄的指针。

### Return value

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

成功时返回 **S\_OK**；否则，返回错误代码。有关错误代码列表，请参阅[错误代码](/reference/errorcodes)。

## Remarks

<Note>此函数在时间敏感线程上调用不安全。有关详细信息，请参阅[时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

屏幕超时延迟可确保在用户不操作期间屏幕不会变暗、锁定或关闭。经过一段空闲时间后，会发生屏幕超时。响应屏幕超时时，设备可能会使显示器变暗、激活锁屏或关闭显示器。发生屏幕超时前所需的空闲时间取决于设备的用户设置。如果游戏正在执行不需要用户交互的活动（如加载游戏资源或显示长过场动画），屏幕超时可能会带来不便。可以通过获取屏幕超时延迟来防止屏幕超时。

若要获取屏幕超时延迟，请先调用 **XDisplayAcquireTimeoutDeferral** 获取屏幕超时延迟句柄，然后在不再需要该句柄时调用 [XDisplayCloseTimeoutDeferralHandle](/reference/system/xdisplay/functions/xdisplayclosetimeoutdeferralhandle) 关闭它。如果游戏失去焦点，屏幕超时延迟将被忽略，并且当游戏退出时它们将被释放。

<Note>如果使用此函数获取屏幕超时延迟句柄，则必须通过调用 **XDisplayCloseTimeoutDeferralHandle** 关闭该句柄。可以获取多个屏幕超时延迟句柄，仅当所有屏幕超时延迟句柄都关闭后，才会为游戏启用屏幕超时。</Note>

<Note>当标题正在主动被调试时，不会发生屏幕变暗。</Note>

下面的示例在调用 **XDisplayAcquireTimeoutDeferral** 获取新的屏幕超时延迟句柄后播放较长的介绍过场动画。如果成功获取新句柄，长介绍过场动画就可以播放，而不会因用户不操作而导致屏幕超时。过场动画播放完毕后，示例调用 **XDisplayCloseTimeoutDeferralHandle** 关闭句柄。所有屏幕超时延迟句柄都关闭后，屏幕超时可以在用户不操作时再次发生。

```cpp theme={null}
void Game::PlayIntroCutscene()
{
    XDisplayTimeoutDeferralHandle handle;

    // Try to acquire a new timeout deferral handle.
    if (SUCCEEDED(XDisplayAcquireTimeoutDeferral(&handle)))
    {
        // The newly-opened timeout deferral handle prevents the display
        // from dimming over the game if the user goes idle.
        // 
        // At this point, the long intro cutscene can play without dimmming.
    }

    // Once the cutscene has completed playing, 
    // close the timeout deferral handle.
    XDisplayCloseTimeoutDeferralHandle(handle);

    // If there are no open timeout deferral handles, the display can
    // once again dim over the game if the user goes idle.
}
```

## Requirements

**头文件：** XDisplay.h

**库：** xgameruntime.lib

**受支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## Conceptual documentation

* [时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XDisplayCloseTimeoutDeferralHandle](/reference/system/xdisplay/functions/xdisplayclosetimeoutdeferralhandle)\
[XDisplay](/reference/system/xdisplay/xdisplay_members)
