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); } }
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); } }