Exemplo n.º 1
0
        public static async Task Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .Build();
            var appSettings = config.GetSection("AppSettings").Get <AppSettings>();

            InitCommand.DoInit(appSettings);

            while (true)
            {
                try {
                    Console.WriteLine($"Running commands, start at {DateTime.Now.ToShortTimeString()}");
                    await Task.WhenAll(
                        Run(appSettings),
                        Task.Delay(60 * 60 * 1000));

                    Console.WriteLine($"Finished run at {DateTime.Now.ToShortTimeString()}");
                }
                catch (Exception excep)
                {
                    Console.Error.WriteLine(excep.Message);
                    await Task.Delay(60 * 60 * 1000);
                }
            }
        }