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

# RegisterLampArrayCallback

> RegisterLampArrayCallback

# RegisterLampArrayCallback

LampArray가 시스템에 연결되거나 시스템에서 연결 해제될 때마다 호출되는 콜백 함수를 등록합니다.

## 구문

```cpp theme={null}
HRESULT RegisterLampArrayCallback(
    LampArrayCallback lampArrayCallback,
    void* context,
    LampArrayCallbackToken* callbackToken);
```

### 매개변수

*lampArrayCallback*   \_In\_
형식: [LampArrayCallback](/reference/lighting/lamparray/functions/lamparraycallback)

등록할 호출자 정의 함수입니다. LampArrays가 시스템에 연결되거나 연결 해제될 때 호출됩니다.

*context*   \_In\_opt\_\
형식: void\*

콜백 함수에 관련된 정보를 포함하는 개체에 대한 포인터입니다. 일반적으로 이는 호출 개체입니다.

*callbackToken*   \_Out\_ \_Result\_zeroonfailure\_
형식: LampArrayCallbackToken\*

나중에 콜백 함수 등록을 해제하는 데 사용할 수 있는 토큰 값입니다.

### 반환값

형식: HRESULT

함수 결과입니다.

## 설명

콜백이 등록될 때 LampArray 장치가 연결되어 있다면, RegisterLampArrayCallback 함수는 연결된 각 장치에 대해 콜백이 호출될 때까지 블록됩니다. 즉, 콜백은 호출 스레드에서 실행됩니다.

첫 번째 콜백이 등록되면 LampArray API는 ILampArray 장치 연결 및 제거 알림을 처리하기 위한 워커 스레드를 시작합니다. 이러한 이벤트는 자주 발생하지 않으며, 그 외에는 워커 스레드가 대기 상태로 유지됩니다. 등록 호출이 반환된 이후에는 모든 후속 LampArrayCallbacks가 이 워커 스레드에서 순차적으로 호출됩니다.

다음 코드는 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 콘솔

## 함께 보기

[Lighting API 개요](/build/core-features/common/lighting/gc-lighting-toc)\
[Lighting 기본 사항](/build/core-features/common/lighting/lighting-basics)\
[LampArrayCallback](/reference/lighting/lamparray/functions/lamparraycallback)\
[UnregisterLampArrayCallback](/reference/lighting/lamparray/functions/unregisterlamparraycallback)


## Related topics

- [LampArray](/ko/reference/lighting/lamparray/lamparray_members.md)
- [LampArrayCallback](/ko/reference/lighting/lamparray/functions/lamparraycallback.md)
- [UnregisterLampArrayCallback](/ko/reference/lighting/lamparray/functions/unregisterlamparraycallback.md)
- [RegisterLampArrayStatusCallback](/ko/reference/lighting/lamparray/functions/registerlamparraystatuscallback.md)
- [LampArrayStatusCallback](/ko/reference/lighting/lamparray/functions/lamparraystatuscallback.md)
