Ejemplo n.º 1
0
        public static void Main(string[] args = null)
        {
            try
            {
                var tokenSource = new CancellationTokenSource();
                var config      = QueueConsumerConfiguration.Create();
                DisplayHeader(config);

                var processor = new QueueMessageProcessor(config);

                var task = new Task(() =>
                {
                    while (!processor.Execute())
                    {
                    }
                }, tokenSource.Token);

                Console.CancelKeyPress += (sender, eventArgs) =>
                {
                    Console.WriteLine("Aborting Program...");
                    tokenSource.Cancel();
                    task.Dispose();
                };

                task.Start();
                task.Wait();
            }
            catch (Exception e)
            {
                Console.WriteLine("Program Exception:");
                Console.WriteLine(" - {0}\n\n{1}", e.Message, e.StackTrace);
            }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args = null)
        {
            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            ServicePointManager.ServerCertificateValidationCallback  = delegate { return(true); };

            try
            {
                var tokenSource = new CancellationTokenSource();
                var config      = QueueConsumerConfiguration.Create();
                DisplayHeader(config);

                var processor = new QueueMessageProcessor(config);

                var task = new Task(() =>
                {
                    while (!processor.Execute())
                    {
                    }
                }, tokenSource.Token);

                Console.CancelKeyPress += (sender, eventArgs) =>
                {
                    Console.WriteLine("Aborting Program...");
                    tokenSource.Cancel();
                    task.Dispose();
                };

                task.Start();
                task.Wait();
            }
            catch (Exception e)
            {
                Console.WriteLine("Program Exception:");
                Console.WriteLine(" - {0}\n\n{1}", e.Message, e.StackTrace);
            }
        }