Managing Shutdown

This document explains how to handle and acknowledge shutdown notification and close the session.

Before you start, you must know:

  • the APIs for components that must be system state aware.

  • the shutdown state events such as Start-up, Normal, Shutdown and Fail.

The AcknowledgeAndRequestStateNotification() acknowledges the request and registers the component for any state changes. The AcknowledgeAndRequestStateNotification() is called if the component needs another state change notification else AcknowledgeStateNotification() is called. These functions are called only after the clean-up task is completed.

Follow the steps given below to handle and acknowledge shutdown notification, and also to close the session:


  1. Handle and Acknowledge shutdown notification.

    1. Acknowledge the request and register the component for any state changes as shown in the code snippet using AcknowledgeAndRequestStateNotification().
      iStateAwareSession.AcknowledgeAndRequestStateNotification( KErrNone, iStatus );

    2. Handle the acknowledge the state change and request notification for the next state change as shown in the code snippet using AcknowledgeStateNotification()
      iStateAwareSession.AcknowledgeStateNotification( KErrNone );

  2. Close the session

    1. Free the resources that were used during the Connect() as shown in the code snippet using the Close().
      
      CExample::~CExample
      {
          iStateAwareSession.Close();
      }
      

The component is acknowledged for the shutdown notification and the session is closed.