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

> Unregisters a previously registered LampArrayCallback using its callback token and waits up to a specified timeout for in-flight callbacks to finish.

# UnregisterLampArrayCallback

Unregisters a LampArray callback function.

## Syntax

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

### Parameters

*callbackToken*\
Type: LampArrayCallbackToken

Token for the callback function to be unregistered. Generated when the function was initially registered with [RegisterLampArrayCallback](/reference/lighting/lamparray/functions/registerlamparraycallback).

*timeoutInMicroseconds*\
Type: uint64\_t

Amount of time to wait for a callback to finish so it may be unregistered.

### Return value

Type: bool

True if callback was unregistered successfully. False indicates an invalid callback token value, or a timeout while waiting for an in progress callback to return. A false return will still ensure no new callback will be dispatched. Callbacks already in progress will still be executed.

## Remarks

It is not safe to free any resources associated with the callback (for example, unloading the DLL that hosts the callback function) until the UnregisterLampArrayCallback function successfully returns. Therefore, it is not possible to unregister a callback from within its registered callback function, and attempting to do so will terminate the process.

The following code is an example of registering and unregistering a LampArray callback:

```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);
    }
}
```

## Requirements

**Header:** LampArray.h

**Library:** xgameplatform.lib

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

## See also

[Lighting API Overview](/build/core-features/common/lighting/gc-lighting-toc)\
[Lighting Basics](/build/core-features/common/lighting/lighting-basics)\
[LampArrayCallback](/reference/lighting/lamparray/functions/lamparraycallback)\
[RegisterLampArrayCallback](/reference/lighting/lamparray/functions/registerlamparraycallback)


## Related topics

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