Exemple #1
0
        public static void Main(string[] args)
        {
            Logger.Erroring += Console.Error.WriteLine;
            Logger.Warning  += Console.Out.WriteLine;

#if DEBUG
            Logger.Debugging += Console.Out.WriteLine;
#endif

            ParseArguments(args);

            if (headless)
            {
                HideConsole(false, Console.Title);
            }

            if (string.IsNullOrEmpty(configuration) && !File.Exists(configuration))
            {
                Logger.Error("No configuration file is specified or file is not found");
                return;
            }

            var manager = new Workers(configuration);
            var workers = new Dictionary <Guid, IWorker>();

            manager.Load(workers);

            foreach (var worker in workers.Values)
            {
                RunSafe(() => worker.StartWorker());
            }

            AppDomain.CurrentDomain.ProcessExit += (sender, arg) =>
            {
                foreach (var worker in workers.Values)
                {
                    RunSafe(() => worker.AbortWorker());
                }
                manager.Save(workers);
            };

            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                ;
            }
        }
Exemple #2
0
 private void LoadWorkers()
 {
     manager.Load(workers);
 }