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

> RegisterLampArrayStatusCallback

# RegisterLampArrayStatusCallback

LampArray のステータスが変更されるたびに呼び出されるコールバック関数を登録します。

## 構文

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

### パラメーター

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

登録する呼び出し元定義の関数です。LampArray のステータスが変更されると呼び出されます。

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

[LampArrayStatusCallback](/reference/lighting/lamparray/functions/lamparraystatuscallback) 関数の望ましいデバイス列挙動作を指定します。

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

コールバック関数に関連する情報を含むオブジェクトへのポインター。通常は呼び出し元オブジェクトです。

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

後でコールバック関数の登録を解除するために使用できるトークン値です。

### 戻り値

Type: HRESULT

関数の結果です。

## 解説

LampArrayEnumerationKind パラメーターにより、呼び出し元は呼び出し時に接続されている LampArray デバイスに対してコールバックをどのように受信するかを指定できます。[LampArrayEnumerationKind::Blocking](/reference/lighting/lamparray/enums/lamparrayenumerationkind) が選択されている場合、[RegisterLampArrayStatusCallback](/reference/lighting/lamparray/functions/registerlamparraystatuscallback) 関数は、接続されている各デバイスに対してコールバックが呼び出されるまでブロックします (つまり、コールバックは呼び出し元のスレッドで呼び出されます)。

最初のコールバックが登録されると、LampArray API はワーカー スレッドを起動して、ILampArray デバイスのステータス通知を処理します。これらのイベントは頻繁ではなく、ワーカー スレッドはそれ以外のときは待機状態のままです。登録呼び出しが返された後、後続のすべての LampArrayStatusCallbacks はこのワーカー スレッド上で順次呼び出されます。

[LampArrayEnumerationKind::Async](/reference/lighting/lamparray/enums/lamparrayenumerationkind) が指定されている場合、この呼び出しは即座に戻り、呼び出し時に接続されている LampArray は、前述の LampArray コールバック ワーカー スレッド上で列挙されます。

次のコードは、[LampArrayStatusCallback](/reference/lighting/lamparray/functions/lamparraystatuscallback) 関数の登録と登録解除の例です。

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

## 要件

**ヘッダー:** 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)\
[LampArrayStatusCallback](/reference/lighting/lamparray/functions/lamparraystatuscallback)\
[UnregisterLampArrayCallback](/reference/lighting/lamparray/functions/unregisterlamparraycallback)\
[LampArrayEnumerationKind](/reference/lighting/lamparray/enums/lamparrayenumerationkind)


## Related topics

- [LampArrayStatusCallback](/ja-jp/reference/lighting/lamparray/functions/lamparraystatuscallback.md)
- [LampArrayEnumerationKind 列挙型](/ja-jp/reference/lighting/lamparray/enums/lamparrayenumerationkind.md)
- [Lighting API リファレンス](/ja-jp/reference/lighting/gc-reference-lighting-toc.md)
- [RegisterLampArrayCallback](/ja-jp/reference/lighting/lamparray/functions/registerlamparraycallback.md)
- [LampArrayCallback](/ja-jp/reference/lighting/lamparray/functions/lamparraycallback.md)
