static void subscribe(int domain_id, int sample_count)
    {
        // --- Create participant --- //

        /* To customize the participant QoS, use
        the configuration file USER_QOS_PROFILES.xml */
        DDS.DomainParticipant participant =
        DDS.DomainParticipantFactory.get_instance().create_participant(
            domain_id,
            DDS.DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_NONE);
        if (participant == null) {
            shutdown(participant);
            throw new ApplicationException("create_participant error");
        }

        // --- Create subscriber --- //

        /* To customize the subscriber QoS, use
        the configuration file USER_QOS_PROFILES.xml */

        /* The listener has been modified */

        /* Start changes for Ordered Presentation Example */
        /* Note that the StatusKind is DATA_ON_READERS_STATUS in order
         * to the incoming data can be read by the SubscriberListener
         */

        ordered_groupSubscriberListener subscriber_listener =
            new ordered_groupSubscriberListener();

        DDS.Subscriber subscriber = participant.create_subscriber(
            DDS.DomainParticipant.SUBSCRIBER_QOS_DEFAULT,
            subscriber_listener,
            (DDS.StatusMask)DDS.StatusKind.DATA_ON_READERS_STATUS);
        if (subscriber == null) {
            shutdown(participant);
            subscriber_listener = null;
            throw new ApplicationException("create_subscriber error");
        }

        /* End changes for Ordered Presentation Example */

        // --- Create topics --- //

        /* Register the type before creating the topic */
        System.String type_name = ordered_groupTypeSupport.get_type_name();
        try {
            ordered_groupTypeSupport.register_type(
                participant, type_name);
        }
        catch(DDS.Exception e) {
            Console.WriteLine("register_type error {0}", e);
            shutdown(participant);
            throw e;
        }

        /* Start changes for Ordered Presentation Example */

        /* TOPICS */

        /* To customize the topic QoS, use
        the configuration file USER_QOS_PROFILES.xml */
        DDS.Topic topic1 = participant.create_topic(
            "Topic1",
            type_name,
            DDS.DomainParticipant.TOPIC_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_NONE);
        if (topic1 == null) {
            shutdown(participant);
            throw new ApplicationException("create_topic error");
        }

        DDS.Topic topic2 = participant.create_topic(
            "Topic2",
            type_name,
            DDS.DomainParticipant.TOPIC_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_NONE);
        if (topic2 == null) {
            shutdown(participant);
            throw new ApplicationException("create_topic error");
        }

        DDS.Topic topic3 = participant.create_topic(
            "Topic3",
            type_name,
            DDS.DomainParticipant.TOPIC_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_NONE);
        if (topic3 == null) {
            shutdown(participant);
            throw new ApplicationException("create_topic error");
        }

        /* DATAREADERS */

        /* To customize the data reader QoS, use
        the configuration file USER_QOS_PROFILES.xml */
        DDS.DataReader reader1 = subscriber.create_datareader(
            topic1,
            DDS.Subscriber.DATAREADER_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_ALL);
        if (reader1 == null) {
            shutdown(participant);
            throw new ApplicationException("create_datareader error");
        }

        DDS.DataReader reader2 = subscriber.create_datareader(
            topic2,
            DDS.Subscriber.DATAREADER_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_ALL);
        if (reader2 == null) {
            shutdown(participant);
            throw new ApplicationException("create_datareader error");
        }

        DDS.DataReader reader3 = subscriber.create_datareader(
            topic3,
            DDS.Subscriber.DATAREADER_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_ALL);
        if (reader3 == null) {
            shutdown(participant);
            throw new ApplicationException("create_datareader error");
        }

        /* End changes for Ordered Presentation Example */

        // --- Wait for data --- //

        /* Main loop */
        const System.Int32 receive_period = 4000; // milliseconds
        for (int count=0;
        (sample_count == 0) || (count < sample_count);
        ++count) {
            Console.WriteLine(
                "ordered_group subscriber sleeping for {0} sec...",
            receive_period / 1000);

            System.Threading.Thread.Sleep(receive_period);
        }

        // --- Shutdown --- //

        /* Delete all entities */
        shutdown(participant);
        subscriber_listener = null;
    }
    static void subscribe(int domain_id, int sample_count)
    {
        // --- Create participant --- //

        /* To customize the participant QoS, use
         * the configuration file USER_QOS_PROFILES.xml */
        DDS.DomainParticipant participant =
            DDS.DomainParticipantFactory.get_instance().create_participant(
                domain_id,
                DDS.DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT,
                null /* listener */,
                DDS.StatusMask.STATUS_MASK_NONE);
        if (participant == null)
        {
            shutdown(participant);
            throw new ApplicationException("create_participant error");
        }

        // --- Create subscriber --- //

        /* To customize the subscriber QoS, use
         * the configuration file USER_QOS_PROFILES.xml */

        /* The listener has been modified */

        /* Start changes for Ordered Presentation Example */

        /* Note that the StatusKind is DATA_ON_READERS_STATUS in order
         * to the incoming data can be read by the SubscriberListener
         */

        ordered_groupSubscriberListener subscriber_listener =
            new ordered_groupSubscriberListener();

        DDS.Subscriber subscriber = participant.create_subscriber(
            DDS.DomainParticipant.SUBSCRIBER_QOS_DEFAULT,
            subscriber_listener,
            (DDS.StatusMask)DDS.StatusKind.DATA_ON_READERS_STATUS);
        if (subscriber == null)
        {
            shutdown(participant);
            subscriber_listener = null;
            throw new ApplicationException("create_subscriber error");
        }

        /* End changes for Ordered Presentation Example */

        // --- Create topics --- //

        /* Register the type before creating the topic */
        System.String type_name = ordered_groupTypeSupport.get_type_name();
        try {
            ordered_groupTypeSupport.register_type(
                participant, type_name);
        }
        catch (DDS.Exception e) {
            Console.WriteLine("register_type error {0}", e);
            shutdown(participant);
            throw e;
        }

        /* Start changes for Ordered Presentation Example */

        /* TOPICS */

        /* To customize the topic QoS, use
         * the configuration file USER_QOS_PROFILES.xml */
        DDS.Topic topic1 = participant.create_topic(
            "Topic1",
            type_name,
            DDS.DomainParticipant.TOPIC_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_NONE);
        if (topic1 == null)
        {
            shutdown(participant);
            throw new ApplicationException("create_topic error");
        }

        DDS.Topic topic2 = participant.create_topic(
            "Topic2",
            type_name,
            DDS.DomainParticipant.TOPIC_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_NONE);
        if (topic2 == null)
        {
            shutdown(participant);
            throw new ApplicationException("create_topic error");
        }

        DDS.Topic topic3 = participant.create_topic(
            "Topic3",
            type_name,
            DDS.DomainParticipant.TOPIC_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_NONE);
        if (topic3 == null)
        {
            shutdown(participant);
            throw new ApplicationException("create_topic error");
        }

        /* DATAREADERS */

        /* To customize the data reader QoS, use
         * the configuration file USER_QOS_PROFILES.xml */
        DDS.DataReader reader1 = subscriber.create_datareader(
            topic1,
            DDS.Subscriber.DATAREADER_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_ALL);
        if (reader1 == null)
        {
            shutdown(participant);
            throw new ApplicationException("create_datareader error");
        }

        DDS.DataReader reader2 = subscriber.create_datareader(
            topic2,
            DDS.Subscriber.DATAREADER_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_ALL);
        if (reader2 == null)
        {
            shutdown(participant);
            throw new ApplicationException("create_datareader error");
        }

        DDS.DataReader reader3 = subscriber.create_datareader(
            topic3,
            DDS.Subscriber.DATAREADER_QOS_DEFAULT,
            null /* listener */,
            DDS.StatusMask.STATUS_MASK_ALL);
        if (reader3 == null)
        {
            shutdown(participant);
            throw new ApplicationException("create_datareader error");
        }

        /* End changes for Ordered Presentation Example */

        // --- Wait for data --- //

        /* Main loop */
        const System.Int32 receive_period = 4000; // milliseconds

        for (int count = 0;
             (sample_count == 0) || (count < sample_count);
             ++count)
        {
            Console.WriteLine(
                "ordered_group subscriber sleeping for {0} sec...",
                receive_period / 1000);

            System.Threading.Thread.Sleep(receive_period);
        }

        // --- Shutdown --- //

        /* Delete all entities */
        shutdown(participant);
        subscriber_listener = null;
    }