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

# UnregisterLampArrayCallback 函式參考

> 使用回呼權杖取消註冊先前註冊的 LampArrayCallback，並在指定的逾時時間內等候進行中的回呼完成。

# UnregisterLampArrayCallback

取消註冊 LampArray 回呼函式。

## 語法

```cpp theme={null}
bool UnregisterLampArrayCallback(
    LampArrayCallbackToken callbackToken,
    uint64_t timeoutInMicroseconds);
```

### 參數

*callbackToken*\
類型：LampArrayCallbackToken

要取消註冊之回呼函式的權杖。此權杖是在函式最初透過 [RegisterLampArrayCallback](/zh-TW/reference/lighting/lamparray/functions/registerlamparraycallback) 註冊時產生。

*timeoutInMicroseconds*\
類型：uint64\_t

等候回呼完成以便取消註冊的時間長度。

### 傳回值

類型：bool

如果回呼已成功取消註冊，則為 True。False 表示回呼權杖值無效，或在等候進行中的回呼傳回時逾時。傳回 false 時仍會確保不會分派新的回呼。已在進行中的回呼仍會執行。

## 備註

在 UnregisterLampArrayCallback 函式成功傳回之前，釋放與回呼相關聯的任何資源 (例如卸載裝載回呼函式的 DLL) 並不安全。因此，無法從其註冊的回呼函式內取消註冊回呼，嘗試這麼做將會終止處理序。

下列程式碼是註冊和取消註冊 LampArray 回呼的範例：

```cpp theme={null}
void MyLampArrayCallback(
    _In_opt_ void* context,
    bool isAttached,
    _In_ ILampArray* lampArray)
{
    if (isAttached)
    {
        // Application-specific code to handle LampArray connection
    }
    else
    {
        // Application-specific code to handle LampArray disconnection
    }
}

void MonitorLampArrays(
    _In_ volatile bool & cancelMonitoring) noexcept
{
    LampArrayCallbackToken token = LAMPARRAY_INVALID_CALLBACK_TOKEN_VALUE;
    if (SUCCEEDED(RegisterLampArrayCallback(
        MyLampArrayCallback,
        nullptr /* context */,
        &token)))
    {
        while (!cancelMonitoring)
        {
            Sleep(100);
        }

        UnregisterLampArrayCallback(token, 5000);
    }
}
```

## 需求

**標頭：** LampArray.h

**程式庫：** xgameplatform.lib

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

## 另請參閱

[照明 API 概觀](/zh-TW/build/core-features/common/lighting/gc-lighting-toc)\
[照明基本概念](/zh-TW/build/core-features/common/lighting/lighting-basics)\
[LampArrayCallback](/zh-TW/reference/lighting/lamparray/functions/lamparraycallback)\
[RegisterLampArrayCallback](/zh-TW/reference/lighting/lamparray/functions/registerlamparraycallback)


## Related topics

- [UnregisterLampArrayCallback](/ja-jp/reference/lighting/lamparray/functions/unregisterlamparraycallback.md)
- [UnregisterLampArrayCallback function reference](/reference/lighting/lamparray/functions/unregisterlamparraycallback.md)
- [Referencia de la función UnregisterLampArrayCallback](/es/reference/lighting/lamparray/functions/unregisterlamparraycallback.md)
- [LampArray](/ko/reference/lighting/lamparray/lamparray_members.md)
- [LampArrayCallback](/zh-CN/reference/lighting/lamparray/functions/lamparraycallback.md)
