public TradingReporter(TradingReporterConfiguration config, ILogger logger)
 {
     Config         = config;
     Logger         = logger;
     _executionTask = new Task(() => { }); // Set _executionTask != null
     _executionTask.RunSynchronously();    // Make _executionTask.IsCompleted = true
     _timer = new Timer(new TimerCallback(TimerProc));
 }
        public static void UpdateFromAppConfig(this TradingReporterConfiguration trConfig)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            ConfigurationManager.RefreshSection("appSettings");
            ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name);

            KeyValueConfigurationCollection settings = config.AppSettings.Settings;

            string str;

            str = settings["ReportingDirrectory"]?.Value;
            trConfig.ReportingDirrectory = !String.IsNullOrWhiteSpace(str) ? str : TradingReporterConfiguration.DefaultReportingDirrectory;

            str = settings["ReportingIntervalInMinutes"]?.Value;
            trConfig.ReportingInterval = (str != null && int.TryParse(str, out int interval) && interval > 0) ? TimeSpan.FromMinutes(interval) : TradingReporterConfiguration.DefaultReportingInterval;

            str = settings["TradingSessionStart"]?.Value;
            trConfig.SessionInfo = (str != null && TimeSpan.TryParse(str, out TimeSpan start)) ? new SessionInfo {
                SessionStart = start
            } : TradingReporterConfiguration.DefaultSessionInfo;
        }