Ejemplo n.º 1
0
        private static void RunThreaded()
        {
            //Set up cancellation token
            var tokenSource = new CancellationTokenSource();
            var token       = tokenSource.Token;

            //Start Threads
            Task[] tasks = new Task[options.ActualThreads];
            for (int i = 0; i < tasks.Length; i++)
            {
                int threadno = i;
                logger.AddType(threadno.ToString());
                tasks[i] = Task.Factory.StartNew(() => SubscribeThreaded(threadno, token), token);
            }

            Console.WriteLine("Subscription Started. Hit enter to quit");
            Console.ReadLine();
            tokenSource.Cancel();
            tasks.ToList().ForEach(x => x.Wait());
        }