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

# XDisplayCloseTimeoutDeferralHandle

> XDisplayCloseTimeoutDeferralHandle

# XDisplayCloseTimeoutDeferralHandle

释放先前通过调用 [XDisplayAcquireTimeoutDeferral](/reference/system/xdisplay/functions/xdisplayacquiretimeoutdeferral) 获取的屏幕超时延迟。

## Syntax

```cpp theme={null}
void XDisplayCloseTimeoutDeferralHandle(  
         XDisplayTimeoutDeferralHandle handle  
)  
```

### Parameters

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

要关闭的屏幕超时延迟的句柄。

### Return value

类型：void

## Remarks

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

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

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

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

下面的示例在调用 [XDisplayAcquireTimeoutDeferral](/reference/system/xdisplay/functions/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

[XDisplayAcquireTimeoutDeferral](/reference/system/xdisplay/functions/xdisplayacquiretimeoutdeferral)\
[XDisplay](/reference/system/xdisplay/xdisplay_members)


## Related topics

- [XDisplayAcquireTimeoutDeferral](/zh-CN/reference/system/xdisplay/functions/xdisplayacquiretimeoutdeferral.md)
- [XDisplay](/zh-CN/reference/system/xdisplay/xdisplay_members.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XUserCloseSignOutDeferralHandle](/zh-CN/reference/system/xuser/functions/xuserclosesignoutdeferralhandle.md)
- [XSystemHandleType](/zh-CN/reference/system/xsystem/enums/xsystemhandletype.md)
