static void Main(string[] args)
        {
            var crawlerService = new CrawlerService();

            crawlerService.Start();

            Console.CancelKeyPress += (sender, eventArgs) => { crawlerService.Stop(); };

            crawlerService.WhenTerminated.Wait();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var crawlerService = new CrawlerService();

            crawlerService.Start();

            AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
            {
                crawlerService.Stop().Wait(TimeSpan.FromSeconds(30));
            };

            Console.CancelKeyPress += async(sender, eventArgs) =>
            {
                await crawlerService.Stop();

                eventArgs.Cancel = true;
            };

            crawlerService.WhenTerminated.Wait();
        }