Esempio n. 1
0
        public static void Main(string[] args)
        {
            CancellationTokenSource source = new CancellationTokenSource();

            var configuration = Configure();

            var consumers = StartListeningToTopics(configuration, source.Token);

            var console = new ConsoleMenuInput(new Menu()
            {
                Items = new List <MenuItem>
                {
                    new MenuItem {
                        Name = "List Products Available", OnSelected = ListProducts
                    },
                    new MenuItem {
                        Name = "Configure Product", OnSelected = ConfigureProduct
                    },
                    new MenuItem {
                        Name = "Publish Product", OnSelected = PublishProduct
                    }
                }
            }).Start(source.Token);

            Task.WaitAll(consumers.Union(new[] { console }).ToArray()); // This will never end, bad cancellation token code
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var configuration = Configure();

            _publisher = new Publisher(configuration.GetOptions <KafkaOptions>("kafka"));

            CancellationTokenSource source = new CancellationTokenSource();

            ConsoleMenuInput menu = new ConsoleMenuInput(new Menu()
            {
                Items = new List <MenuItem>
                {
                    new MenuItem {
                        Name = "Add Product", OnSelected = AddNewProduct
                    }
                }
            });

            Task.WaitAll(menu.Start(source.Token));
        }