/// <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 { AgentConfiguration.Init(); } catch (Exception ex) { throw new AgentFailedToStartException("The agent can not be started", ex); } //Call derived class to perform their initializations/start DoOnStart(); }
/// <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}"); } }
/// <summary> /// Updates the device twin configuration explicitly /// This method ensures the device gets the configuration immediately /// </summary> public void UpdateAgentTwinConfiguration() { AgentConfiguration.Init(); }