private static void Main(string[] args)
        {
            var trackingService = new TrackerService();

            trackingService.Start();

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

            trackingService.WhenTerminated.Wait();
        }
Example #2
0
        private static void Main(string[] args)
        {
            var trackingService = new TrackerService();

            trackingService.Start();

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

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

                eventArgs.Cancel = true;
            };

            trackingService.WhenTerminated.Wait();
        }