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

# Référence de la fonction RegisterLampArrayCallback

> Inscrit un LampArrayCallback déclenché lorsqu'un périphérique LampArray est connecté ou déconnecté, et retourne un jeton permettant de le désinscrire ultérieurement.

# RegisterLampArrayCallback

Inscrit une fonction de rappel à appeler chaque fois qu'un LampArray est connecté au système ou déconnecté de celui-ci.

## Syntaxe

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

### Paramètres

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

Fonction définie par l'appelant à inscrire. Elle est appelée lorsque des LampArrays sont connectés au système ou déconnectés de celui-ci.

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

Pointeur vers un objet contenant des informations pertinentes pour la fonction de rappel. Il s'agit généralement de l'objet appelant.

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

Valeur de jeton pouvant être utilisée pour désinscrire la fonction de rappel ultérieurement.

### Valeur de retour

Type : HRESULT

Résultat de la fonction.

## Remarques

Si des périphériques LampArray sont connectés au moment de l'inscription d'un rappel, la fonction RegisterLampArrayCallback bloque jusqu'à ce que ce rappel soit appelé pour chaque périphérique connecté (ce qui signifie que le rappel est appelé sur le thread appelant).

Lorsque le premier rappel est inscrit, l'API LampArray démarre un thread de travail pour gérer les notifications de connexion et de retrait des périphériques ILampArray. Ces événements sont peu fréquents, et le thread de travail reste sinon en état d'attente. Une fois l'appel d'inscription retourné, tous les LampArrayCallbacks suivants sont appelés séquentiellement sur ce thread de travail.

Le code suivant est un exemple d'inscription et de désinscription d'un rappel 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);
    }
}
```

## Configuration requise

**En-tête :** LampArray.h

**Bibliothèque :** xgameplatform.lib

**Plateformes prises en charge :** consoles de la famille XBOX One et consoles XBOX Series

## Voir aussi

[Vue d'ensemble de l'API d'éclairage](/fr/build/core-features/common/lighting/gc-lighting-toc)\
[Notions de base de l'éclairage](/fr/build/core-features/common/lighting/lighting-basics)\
[LampArrayCallback](/fr/reference/lighting/lamparray/functions/lamparraycallback)\
[UnregisterLampArrayCallback](/fr/reference/lighting/lamparray/functions/unregisterlamparraycallback)


## Related topics

- [Referencia de la función RegisterLampArrayCallback](/es/reference/lighting/lamparray/functions/registerlamparraycallback.md)
- [RegisterLampArrayCallback](/ja-jp/reference/lighting/lamparray/functions/registerlamparraycallback.md)
- [RegisterLampArrayCallback function reference](/reference/lighting/lamparray/functions/registerlamparraycallback.md)
- [Referencia de la función LampArrayCallback](/es/reference/lighting/lamparray/functions/lamparraycallback.md)
- [Referencia de la función UnregisterLampArrayCallback](/es/reference/lighting/lamparray/functions/unregisterlamparraycallback.md)
