/// <summary>
        /// Sets up the generation of events, as defined in the configuration, wit hthe proper intervals between them, to avoid overloading the system
        /// </summary>
        /// <param name="scheduler">The scheduler to setup the event generators in</param>
        protected void SetupEventGenerators(TaskScheduler scheduler)
        {
            var      eventGeneratorsProvider = new AppConfigEventGeneratorsProvider();
            var      generators      = eventGeneratorsProvider.GetAll();
            DateTime timeToStartTask = DateTime.UtcNow;
            TimeSpan timeSpanBetweenGeneratorInvocation = new TimeSpan(LocalConfiguration.General.ProducerInterval.Ticks / generators.Count());

            foreach (var generator in generators)
            {
                EventProducer producer = new EventProducer(generator);
                scheduler.AddTask(producer, LocalConfiguration.General.ProducerInterval, timeToStartTask);
                timeToStartTask = timeToStartTask.Add(timeSpanBetweenGeneratorInvocation);
            }
        }
 /// <summary>
 /// Starts the agent execution
 /// Performs required initializations and calls abstract function DoOnStart() to perform any action required by the derived class
 /// </summary>
 public void Start()
 {
     //Load the agent configurations
     try
     {
         SimpleLogger.Information("Agent is initializing...", sendAsDiagnostic: true);
         AgentConfiguration.Init();
         var eventGeneratorsProvider = new AppConfigEventGeneratorsProvider();
         EventGenerators = eventGeneratorsProvider.GetAll();
         SimpleLogger.Information("Agent is initialized!");
         //Call derived class to perform their initializations/start
         DoOnStart();
     }
     catch (AgentException ex)
     {
         SimpleLogger.Fatal($"ASC for IoT agent encountered an error! {ex.Message}");
     }
     catch (TypeInitializationException ex) when(ex.InnerException is AgentException)
     {
         SimpleLogger.Fatal($"ASC for IoT agent encountered an error! {ex.InnerException.Message}");
     }
 }