Exemplo n.º 1
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private static void Main(string[] args)
        {
            LogManager.Adapter = new ConsoleOutLoggerFactoryAdapter();

            Params = ProducerParams.ReadFromAppSettings();

            Console.WriteLine("Starting producer [{0}]...", Params.Endpoint);
            using (Bus = new BusFactory().Create(ConfigureBus))
            {
                var cancellationTokenSource = new CancellationTokenSource();
                CancellationToken token     = cancellationTokenSource.Token;

                Task[] emittingTasks = Enumerable.Range(0, Params.EmittingThreads).
                                       Select(i => Task.Factory.StartNew(CreateEmitter(i, token), token)).
                                       ToArray();

                Console.ReadKey(true);
                Console.WriteLine("Shutting down producer [{0}]...", Params.Endpoint);

                cancellationTokenSource.Cancel();
                Task.WaitAll(emittingTasks);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private static void Main(string[] args)
        {
            LogManager.Adapter = new ConsoleOutLoggerFactoryAdapter();

            Params = ProducerParams.ReadFromAppSettings();

            Console.WriteLine("Starting producer [{0}]...", Params.Endpoint);
            using (Bus = new BusFactory().Create(ConfigureBus))
            {
                var cancellationTokenSource = new CancellationTokenSource();
                CancellationToken token = cancellationTokenSource.Token;

                Task[] emittingTasks = Enumerable.Range(0, Params.EmittingThreads).
                    Select(i => Task.Factory.StartNew(CreateEmitter(i, token), token)).
                    ToArray();

                Console.ReadKey(true);
                Console.WriteLine("Shutting down producer [{0}]...", Params.Endpoint);

                cancellationTokenSource.Cancel();
                Task.WaitAll(emittingTasks);
            }
        }