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

# XThreadSetTimeSensitive

> XThreadSetTimeSensitive

# XThreadSetTimeSensitive

将线程设置为或清除为时间敏感。

## Syntax

```cpp theme={null}
HRESULT XThreadSetTimeSensitive(  
         bool isTimeSensitiveThread  
)  
```

### Parameters

*isTimeSensitiveThread*   \_In\_\
类型：bool

设置为 `true` 可将调用线程设置为时间敏感；否则设置为 `false`。

### Return value

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

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

## Remarks

此函数将调用线程设置为或清除为*时间敏感线程*（不应在其上执行阻塞或长时间运行的操作）。此函数在线程本地存储中设置或清除一个位，游戏运行时服务 (GRTS) API 可以查询该位。只有时间敏感–安全的 GRTS API 才能在时间敏感线程上调用。有关详细信息，请参阅[时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。

在非时间敏感的方法开始处使用 [XThreadAssertNotTimeSensitive](/reference/system/xthread/functions/xthreadassertnottimesensitive) 函数，以便在时间敏感线程上调用该方法时中断到调试器。

根据需要，使用 [XThreadIsTimeSensitive](/reference/system/xthread/functions/xthreadistimesensitive) 函数在运行时测试调用线程是否为时间敏感线程。

## Requirements

**头文件：** XThread.h

**库：** xgameruntime.lib

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

## Conceptual documentation

* [异步编程设计目标和改进](/build/core-features/common/async/async-whitepaper)
* [时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XThread](/reference/system/xthread/xthread_members)\
[时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)


## Related topics

- [XThread](/zh-CN/reference/system/xthread/xthread_members.md)
- [XThreadIsTimeSensitive](/zh-CN/reference/system/xthread/functions/xthreadistimesensitive.md)
- [XThreadAssertNotTimeSensitive](/zh-CN/reference/system/xthread/functions/xthreadassertnottimesensitive.md)
- [XClosedCaptionSetEnabled](/zh-CN/reference/system/xaccessibility/functions/xclosedcaptionsetenabled.md)
- [XSpeechToTextSetPositionHint](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextsetpositionhint.md)
