public async Task <string> OpenAsync(CancellationToken cancellationToken)
        {
            this.m_MessagingFactory = MessagingFactory.CreateFromConnectionString(this.EventHubConnectionString);
            this.m_EventHubClient   = this.m_MessagingFactory.CreateEventHubClient(this.EventHubName);
            this.m_ConsumerGroup    = !string.IsNullOrEmpty(this.EventHubConsumerGroupName)
                ? this.m_EventHubClient.GetConsumerGroup(this.EventHubConsumerGroupName)
                : this.m_EventHubClient.GetDefaultConsumerGroup();


            // slice the pie according to distribution
            // this partition can get one or more assigned Event Hub Partition ids
            string[] EventHubPartitionIds  = this.m_EventHubClient.GetRuntimeInformation().PartitionIds;
            string[] assignedPartitionsIds = await this.ResolveEventHubPartitions(EventHubPartitionIds);

            this.m_EventProcessorFactory = new EventProcessorFactory(this.Handler, this.EventHubName, this.Namespace, this.EventHubConsumerGroupName);
            CheckPointManager checkPointManager = new CheckPointManager();


            this.m_TraceWriter.TraceMessage(
                string.Format(
                    "Event Hub Listener for {0} on {1} using mode:{2} handling:{3}/{4} event hub partitions",
                    this.EventHubName,
                    this.Namespace,
                    this.ListenerMode,
                    assignedPartitionsIds.Count(),
                    EventHubPartitionIds.Count()));


            foreach (string pid in assignedPartitionsIds)
            {
                StateManagerLease lease =
                    await
                    StateManagerLease.GetOrCreateAsync(
                        this.StateManager,
                        this.StateDictionary,
                        this.m_Namespace,
                        this.EventHubConsumerGroupName,
                        this.EventHubName,
                        pid);


                await this.m_ConsumerGroup.RegisterProcessorFactoryAsync(
                    lease,
                    checkPointManager,
                    this.m_EventProcessorFactory);
            }


            return(string.Concat(this.EventHubName, " @ ", this.Namespace));
        }
        public async Task<string> OpenAsync(CancellationToken cancellationToken)
        {
            this.m_MessagingFactory = MessagingFactory.CreateFromConnectionString(this.EventHubConnectionString);
            this.m_EventHubClient = this.m_MessagingFactory.CreateEventHubClient(this.EventHubName);
            this.m_ConsumerGroup = !string.IsNullOrEmpty(this.EventHubConsumerGroupName)
                ? this.m_EventHubClient.GetConsumerGroup(this.EventHubConsumerGroupName)
                : this.m_EventHubClient.GetDefaultConsumerGroup();


            // slice the pie according to distribution
            // this partition can get one or more assigned Event Hub Partition ids
            string[] EventHubPartitionIds = this.m_EventHubClient.GetRuntimeInformation().PartitionIds;
            string[] assignedPartitionsIds = await this.ResolveEventHubPartitions(EventHubPartitionIds);

            this.m_EventProcessorFactory = new EventProcessorFactory(this.Handler, this.EventHubName, this.Namespace, this.EventHubConsumerGroupName);
            CheckPointManager checkPointManager = new CheckPointManager();


            this.m_TraceWriter.TraceMessage(
                string.Format(
                    "Event Hub Listener for {0} on {1} using mode:{2} handling:{3}/{4} event hub partitions",
                    this.EventHubName,
                    this.Namespace,
                    this.ListenerMode,
                    assignedPartitionsIds.Count(),
                    EventHubPartitionIds.Count()));


            foreach (string pid in assignedPartitionsIds)
            {
                StateManagerLease lease =
                    await
                        StateManagerLease.GetOrCreateAsync(
                            this.StateManager,
                            this.StateDictionary,
                            this.m_Namespace,
                            this.EventHubConsumerGroupName,
                            this.EventHubName,
                            pid);


                await this.m_ConsumerGroup.RegisterProcessorFactoryAsync(
                    lease,
                    checkPointManager,
                    this.m_EventProcessorFactory);
            }


            return string.Concat(this.EventHubName, " @ ", this.Namespace);
        }