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

# RegisterLampArrayStatusCallback function

> Registers a LampArrayStatusCallback that fires on LampArray status changes and controls whether initial device enumeration blocks or runs async.

# RegisterLampArrayStatusCallback

Registers a callback function to be invoked each time the LampArray status changes.

## Syntax

```cpp theme={null}
STDAPI RegisterLampArrayStatusCallback(
    _In_ LampArrayStatusCallback callbackFunc,
    LampArrayEnumerationKind enumerationKind,
    _In_opt_ void * context,
    _Out_ _Result_zeroonfailure_ LampArrayCallbackToken * callbackToken);
```

### Parameters

*callbackFunc*   \_In\_
Type: [LampArrayStatusCallback](/reference/lighting/lamparray/functions/lamparraystatuscallback)

A caller-defined function to register. It will be invoked when LampArray status changes.

*enumerationKind*\
Type: [LampArrayEnumerationKind](/reference/lighting/lamparray/enums/lamparrayenumerationkind)

Specifies the desired device enumeration behavior of the [LampArrayStatusCallback](/reference/lighting/lamparray/functions/lamparraystatuscallback) function.

*context*   \_In\_opt\_\
Type: void\*

A pointer to an object containing relevant information for the callback function. Typically, this is the calling object.

*callbackToken*   \_Out\_ \_Result\_zeroonfailure\_
Type: LampArrayCallbackToken\*

A token value that can be used to unregister the callback function at a later time.

### Return value

Type: HRESULT

Function result.

## Remarks

The LampArrayEnumerationKind parameter allows the caller to specify how it should receive callbacks for any LampArray devices that are attached at the time of this call. If [LampArrayEnumerationKind::Blocking](/reference/lighting/lamparray/enums/lamparrayenumerationkind) is selected, the [RegisterLampArrayStatusCallback](/reference/lighting/lamparray/functions/registerlamparraystatuscallback) function will block until that callback is invoked for each attached device (meaning the callback will be invoked on the calling thread).

When the first callback is registered, the LampArray API starts a worker thread to handle ILampArray device status notifications. These events are infrequent, and the worker thread otherwise remains in a wait state. After the registration call returns, all subsequent LampArrayStatusCallbacks will be invoked sequentially on this worker thread.

If [LampArrayEnumerationKind::Async](/reference/lighting/lamparray/enums/lamparrayenumerationkind) is specified, this call will return immediately, and any LampArrays connected at the time of the call will be enumerated on the aforementioned LampArray callback worker thread.

The following code is an example of registering and unregistering a [LampArrayStatusCallback](/reference/lighting/lamparray/functions/lamparraystatuscallback) function:

```c++ theme={null}
void MyLampArrayStatusCallback(
    _In_opt_ void* context,
    LampArrayStatus currentStatus,
    LampArrayStatus previousStatus,
    _In_ ILampArray* lampArray)
{
    // Application-specific code to handle LampArray status changes
}

void MonitorLampArrays(
    _In_ volatile bool & cancelMonitoring) noexcept
{
    LampArrayCallbackToken token = LAMPARRAY_INVALID_CALLBACK_TOKEN_VALUE;
    if (SUCCEEDED(RegisterLampArrayStatusCallback(
        MyLampArrayStatusCallback,
        LampArrayEnumerationKind::Async,
        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)\
[LampArrayStatusCallback](/reference/lighting/lamparray/functions/lamparraystatuscallback)\
[UnregisterLampArrayCallback](/reference/lighting/lamparray/functions/unregisterlamparraycallback)\
[LampArrayEnumerationKind](/reference/lighting/lamparray/enums/lamparrayenumerationkind)


## Related topics

- [LampArrayEnumerationKind enum reference](/reference/lighting/lamparray/enums/lamparrayenumerationkind.md)
- [LampArrayStatusCallback function reference](/reference/lighting/lamparray/functions/lamparraystatuscallback.md)
- [RegisterLampArrayCallback function reference](/reference/lighting/lamparray/functions/registerlamparraycallback.md)
- [LampArrayCallback function reference](/reference/lighting/lamparray/functions/lamparraycallback.md)
- [UnregisterLampArrayCallback function reference](/reference/lighting/lamparray/functions/unregisterlamparraycallback.md)
