async Task StartProcessor(CancellationToken token)
        {
            try
            {
                // Initialize
                this.eventProcessorHost = new EventProcessorHost(
                    Environment.MachineName,
                    configurationProvider.GetConfigurationSettingValue("eventHub.HubName").ToLower(),
                    EventHubConsumerGroup.DefaultGroupName,
                    configurationProvider.GetConfigurationSettingValue("eventHub.ConnectionString"),
                    configurationProvider.GetConfigurationSettingValue("eventHub.StorageConnectionString"));

                this.factory = new DeviceAdministrationProcessorFactory(_deviceLogic, configurationProvider);
                Trace.TraceInformation("DeviceEventProcessor: Registering host...");
                var options = new EventProcessorOptions();
                options.ExceptionReceived += OptionsOnExceptionReceived;
                await this.eventProcessorHost.RegisterEventProcessorFactoryAsync(factory);

                // processing loop
                while (!token.IsCancellationRequested)
                {
                    Trace.TraceInformation("DeviceEventProcessor: Processing...");
                    await Task.Delay(TimeSpan.FromMinutes(5), token);

                    // Any additional incremental processing can be done here (like checking states, etc).
                }

                // cleanup
                await this.eventProcessorHost.UnregisterEventProcessorAsync();
            }
            catch (Exception e)
            {
                Trace.TraceInformation("Error in DeviceEventProcessor.StartProcessor, Exception: {0}", e.Message);
            }
            this.running = false;
        }
        async Task StartProcessor(CancellationToken token)
        {
            try
            {
                // Initialize
                this.eventProcessorHost = new EventProcessorHost(
                    Environment.MachineName,
                    configurationProvider.GetConfigurationSettingValue("eventHub.HubName").ToLower(),
                    EventHubConsumerGroup.DefaultGroupName,
                    configurationProvider.GetConfigurationSettingValue("eventHub.ConnectionString"),
                    configurationProvider.GetConfigurationSettingValue("eventHub.StorageConnectionString"));

                this.factory = new DeviceAdministrationProcessorFactory(_deviceLogic, configurationProvider);
                Trace.TraceInformation("DeviceEventProcessor: Registering host...");
                var options = new EventProcessorOptions();
                options.ExceptionReceived += OptionsOnExceptionReceived;
                await this.eventProcessorHost.RegisterEventProcessorFactoryAsync(factory);

                // processing loop
                while (!token.IsCancellationRequested)
                {
                    Trace.TraceInformation("DeviceEventProcessor: Processing...");
                    await Task.Delay(TimeSpan.FromMinutes(5), token);

                    // Any additional incremental processing can be done here (like checking states, etc).
                }

                // cleanup
                await this.eventProcessorHost.UnregisterEventProcessorAsync();
            }
            catch (Exception e)
            {
                Trace.TraceInformation("Error in DeviceEventProcessor.StartProcessor, Exception: {0}", e.Message);
            }
            this.running = false;
        }