示例#1
0
        static void Main(string[] args)
        {
            var factory = new ActionDispatcherFactory(new Workerhandler());

            DisaptcherToken = factory.Start(new ActionDispatcherSettings
            {
                Schedule = ScheduleType.Parallel,
                Timeout  = TimeSpan.FromSeconds(2)
            });

            var select = args.Length > 0 ? args[0] : default(string) ?? "complete";

            Execute(select, args.Length > 1 ? int.Parse(args[1]) : 100).Wait();

            if (select == "pages")
            {
                Console.ReadKey();
            }

            Console.WriteLine("await stop");
            DisaptcherToken.WaitCompleted(120);
            DisaptcherToken.Dispose();
            Console.WriteLine("stopped success");
            //Console.ReadKey();
        }
        public WorkDispatcherFixture()
        {
            Factory = new ActionDispatcherFactory(MockWorkerHandler.Object);

            DispatcherToken = Factory.Start(new ActionDispatcherSettings
            {
                Timeout = TimeSpan.FromSeconds(10)
            });
        }
示例#3
0
        static void Main(string[] args)
        {
            var factory = new ActionDispatcherFactory(new Workerhandler());

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            DisaptcherToken = factory.Start(new ActionDispatcherSettings
            {
                PrefetchCount = 10,
                Schedule      = ScheduleType.ParallelLimit,
                Timeout       = TimeSpan.FromSeconds(1.5)
            });

            Execute();

            stopwatch.Stop();

            Console.WriteLine($"STOP {stopwatch.Elapsed.TotalSeconds} queue count: {DisaptcherToken.QueueProcessCount}, current count: {DisaptcherToken.ProcessCount}");
        }
示例#4
0
 public Worker2(IDispatcherToken sender)
 {
     _sender = sender;
 }