Partager via


IAgentTransportShutdownCallback

Mise à jour : novembre 2007

Définit les méthodes qu'un objet de rappel d'arrêt doit implémenter.

IAgentTransportShutdownCallback : public IUnknown

Méthodes

Méthode

Description

IAgentTransportShutdownCallback::Shutdown

Donne aux agents côté appareil la possibilité d'effectuer un nettoyage et de quitter.

Notes

Un agent Smart Device est utile tant que conmanclient2.exe s'exécute sur l'appareil. Lorsque conmanclient2.exe est arrêté, tous les agents Smart Device sont également arrêtés. Un agent Smart Device peut demander à recevoir une notification d'arrêt pour effectuer un nettoyage et quitter normalement. Pour recevoir la notification d'arrêt, l'agent Smart Device doit définir une classe qui implémente cette interface, puis l'enregistrer à l'aide de IDeviceAgentTransport::RegisterShutdownCallback.

Exemple

L'exemple ci-dessous définit une implémentation personnalisée de cette interface. Pour accéder à l'intégralité de l'exemple, consultez la rubrique IDeviceAgentTransport.

// Custom implementation of IAgentTransportShutdownCallback
class MyShutdownCallback: public IAgentTransportShutdownCallback
{
private:
    long ref;
public:
    HRESULT STDMETHODCALLTYPE Shutdown(IUnknown *in_pUnknown) 
    {
        // Add your cleanup code here 
        MessageBox(NULL,_T("conmanclient2 exited"),_T("conmanclient exited"),0);
        return 0;
    }

    // Must implement members from IUnknown
    HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
    {
        return 0;
    }
    ULONG STDMETHODCALLTYPE AddRef( void)
    {
        return InterlockedIncrement(&ref);
    }

    ULONG STDMETHODCALLTYPE Release( void)
    {
        if(InterlockedDecrement(&ref) == 0)
        {
            delete this;
            return 0;
        }
        return ref;
    }
};

Équivalent managé

Microsoft.SmartDevice.DeviceAgentTransport.IAgentTransportShutdownCallback

Configuration requise

DeviceAgentTransport.h

Voir aussi

Autres ressources

API de connectivité des appareils de type Smart Device côté appareil non managée