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

將執行緒設定為時間敏感或清除其時間敏感設定。

## 語法

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

### 參數

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

設定為 `true` 可將呼叫執行緒設定為時間敏感；否則為 `false`。

### 傳回值

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

如果成功，則傳回 `S_OK`；否則傳回錯誤碼。如需錯誤碼清單，請參閱[錯誤碼](/zh-TW/reference/errorcodes)。

## 備註

此函式會將呼叫執行緒設定為*時間敏感執行緒*或清除該設定；在時間敏感執行緒上不應執行封鎖或長時間執行的作業。此函式會設定或清除執行緒區域儲存區中的一個位元，可供 Gaming Runtime Services (GRTS) API 查詢。只有時間敏感安全的 GRTS API 才能在時間敏感執行緒上呼叫。如需詳細資訊，請參閱[時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。

在非時間敏感的方法開頭使用 [XThreadAssertNotTimeSensitive](/zh-TW/reference/system/xthread/functions/xthreadassertnottimesensitive) 函式，以便在時間敏感執行緒上呼叫該方法時中斷進入偵錯工具。

視需要使用 [XThreadIsTimeSensitive](/zh-TW/reference/system/xthread/functions/xthreadistimesensitive) 函式在執行階段測試呼叫執行緒是否為時間敏感。

## 需求

**標頭：** XThread.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [非同步程式設計的設計目標與改進](/zh-TW/build/core-features/common/async/async-whitepaper)
* [時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另請參閱

[XThread](/zh-TW/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-TW/reference/system/xthread/xthread_members.md)
- [XThreadIsTimeSensitive](/zh-TW/reference/system/xthread/functions/xthreadistimesensitive.md)
- [XThreadAssertNotTimeSensitive](/zh-TW/reference/system/xthread/functions/xthreadassertnottimesensitive.md)
- [非同步程式設計的設計目標與改進](/zh-TW/build/core-features/common/async/async-whitepaper.md)
- [適用於 GDK 的 Unity C# API 包裝函式](/zh-TW/build/gdk-and-engines/unity/unity-api-wrappers.md)
