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

> UnregisterLampArrayCallback

# UnregisterLampArrayCallback

取消注册 LampArray 回调函数。

## 语法

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

### 参数

*callbackToken*\
类型：LampArrayCallbackToken

要取消注册的回调函数的令牌。该令牌是在最初通过 [RegisterLampArrayCallback](/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 概览](/build/core-features/common/lighting/gc-lighting-toc)\
[光照基础](/build/core-features/common/lighting/lighting-basics)\
[LampArrayCallback](/reference/lighting/lamparray/functions/lamparraycallback)\
[RegisterLampArrayCallback](/reference/lighting/lamparray/functions/registerlamparraycallback)


## Related topics

- [LampArray](/zh-CN/reference/lighting/lamparray/lamparray_members.md)
- [LampArrayCallback](/zh-CN/reference/lighting/lamparray/functions/lamparraycallback.md)
- [LampArrayStatusCallback](/zh-CN/reference/lighting/lamparray/functions/lamparraystatuscallback.md)
- [RegisterLampArrayCallback](/zh-CN/reference/lighting/lamparray/functions/registerlamparraycallback.md)
- [RegisterLampArrayStatusCallback](/zh-CN/reference/lighting/lamparray/functions/registerlamparraystatuscallback.md)
