public EventProcessor()
 {
     configuration = new EventProcessorFactoryConfiguration
     {
         TrackEvent       = e => new object(),
         GetElapsedTime   = () => 0,
         UpdateStatistics = (a, b, c) => {},
         MessageInspector = null,
         WriteToLog       = DummyWriteToLog,
         ServiceBusHelper = null,
     };
 }
 public EventProcessor()
 {
     configuration = new EventProcessorFactoryConfiguration
     {
         TrackEvent = e => new object(),
         GetElapsedTime = () => 0,
         UpdateStatistics = (a, b, c) =>{},
         MessageInspector = null,
         WriteToLog = DummyWriteToLog,
         ServiceBusHelper = null
     };
 }
        // ReSharper disable once FunctionComplexityOverflow
        private async void btnStart_Click(object sender, EventArgs e)
        {
            if (string.Compare(btnStart.Text, Start, StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (startLog != null && checkBoxLogging.Checked)
                {
                    startLog();
                }
                receiverEventDataInspector = cboReceiverInspector.SelectedIndex > 0
                                           ? Activator.CreateInstance(serviceBusHelper.EventDataInspectors[cboReceiverInspector.Text]) as IEventDataInspector
                                           : null;

                cancellationTokenSource = new CancellationTokenSource();
                btnStart.Text = Stop;
                blockingCollection = new BlockingCollection<Tuple<long, long, long>>();
                timer = new System.Timers.Timer
                {
                    AutoReset = true,
                    Enabled = true,
                    Interval = 1000 * txtRefreshInformation.IntegerValue
                };
                timer.Elapsed += timer_Elapsed;
                var ns = serviceBusHelper != null && !string.IsNullOrWhiteSpace(serviceBusHelper.Namespace) ? serviceBusHelper.Namespace : iotHubConnectionString;
                var eventHub = eventHubClient.Path;
                var maxBatchSize = txtMaxBatchSize.IntegerValue > 0 ? txtMaxBatchSize.IntegerValue : 1;
                var receiveTimeout = TimeSpan.FromSeconds(txtReceiveTimeout.IntegerValue);
                try
                {
                    registeredDictionary = new Dictionary<string, bool>(partitionRuntumeInformationList.Count);
                    var startDateTimeEnabled = pickerStartingDateTimeUtc.Checked;
                    var startDateTimeValue = DateTime.SpecifyKind(pickerStartingDateTimeUtc.Value, DateTimeKind.Utc);
                    var eventProcessorOptions = new EventProcessorOptions
                    {
                        InitialOffsetProvider = partitionId =>
                        {
                            if (startDateTimeEnabled)
                            {
                                return startDateTimeValue;
                            }
                            var lease = EventProcessorCheckpointHelper.GetLease(ns,
                                eventHub,
                                consumerGroup.GroupName,
                                partitionId);
                            return lease != null ? lease.Offset : "-1";
                        },
                        MaxBatchSize = maxBatchSize,
                        ReceiveTimeOut = receiveTimeout
                    };
                    eventProcessorOptions.ExceptionReceived += (s, ex) => HandleException(ex.Exception);
                    var checkpointManager = new EventProcessorCheckpointManager
                    {
                        Namespace = ns,
                        EventHub = eventHub,
                        ConsumerGroup = consumerGroup.GroupName
                    };
                    var eventProcessorFactoryConfiguration = new EventProcessorFactoryConfiguration(checkBoxLogging,
                                                                                                    checkBoxTrackMessages,
                                                                                                    checkBoxVerbose,
                                                                                                    checkBoxOffsetInclusive,
                                                                                                    checkBoxCheckpoint,
                                                                                                    cancellationTokenSource.Token)
                    {
                        TrackEvent = ev => Invoke(new Action<EventData>(m => eventDataCollection.Add(m)), ev),
                        GetElapsedTime = GetElapsedTime,
                        UpdateStatistics = UpdateStatistics,
                        WriteToLog = writeToLog,
                        MessageInspector = receiverEventDataInspector,
                        ServiceBusHelper = serviceBusHelper
                    };
                    foreach (var partitionRuntimeInformation in partitionRuntumeInformationList)
                    {
#pragma warning disable 4014
                        consumerGroup.RegisterProcessorFactoryAsync(
#pragma warning restore 4014
EventProcessorCheckpointHelper.GetLease(ns, eventHub, consumerGroup.GroupName, partitionRuntimeInformation.PartitionId),
                                checkpointManager,
                                new EventProcessorFactory<EventProcessor>(eventProcessorFactoryConfiguration),
                                eventProcessorOptions);
                        registeredDictionary.Add(partitionRuntimeInformation.PartitionId, true);
                    }
#pragma warning disable 4014
                    Task.Run(new Action(RefreshGraph));
#pragma warning restore 4014
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                    StopListenerAsync().Wait();
                    btnStart.Text = Start;
                }
            }
            else
            {
                try
                {
                    await StopListenerAsync();
                    btnStart.Text = Start;
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }
        }
 public EventProcessor(EventProcessorFactoryConfiguration configuration)
 {
     this.configuration = configuration;
 }
 public EventProcessor(EventProcessorFactoryConfiguration configuration)
 {
     this.configuration = configuration;
 }