Ejemplo n.º 1
0
        public void TestBackgroundScheduler()
        {
            var scheduler          = new SimpleScheduler();
            var messagingScheduler = new MessagingScheduler(scheduler);

            messagingScheduler.CommandStatusChanged += (sender, args) =>
                                                       Console.WriteLine(args);
            var backgroundScheduler = new BackgroundThreadScheduler(messagingScheduler);
            var thread1             = new Task(() =>
            {
                var guid = Guid.NewGuid();
                foreach (var command in TaskFactory.Parse("Cmd1 Cmd2 Cmd3"))
                {
                    backgroundScheduler.Execute(guid, command);
                }
            });
            var thread2 = new Task(() =>
            {
                var guid = Guid.NewGuid();
                foreach (var command in TaskFactory.Parse("Cmd4 Cmd5 Cmd6"))
                {
                    backgroundScheduler.Execute(guid, command);
                }
            });

            thread1.Start();
            thread2.Start();
            thread1.Wait();
            thread2.Wait();
            Thread.Sleep(10000);
        }
Ejemplo n.º 2
0
        public void TestConsoleMessagingScheduler()
        {
            var scheduler = new ConsoleMessagingScheduler();
            var guid      = Guid.NewGuid();

            foreach (var command in TaskFactory.Parse("Cmd1 Cmd2 Cmd3"))
            {
                scheduler.Execute(guid, command);
            }
        }
Ejemplo n.º 3
0
        public void TestMessagingScheduler()
        {
            AbstractScheduler scheduler = new SimpleScheduler();
            var messagingScheduler      = new MessagingScheduler(scheduler);

            messagingScheduler.CommandStatusChanged += (sender, args) => Console.WriteLine(args);
            var guid = Guid.NewGuid();

            foreach (var command in TaskFactory.Parse("Cmd1 Cmd2 Cmd3"))
            {
                messagingScheduler.Execute(guid, command);
            }
            scheduler = messagingScheduler.Remove <MessagingScheduler>();
            foreach (var command in TaskFactory.Parse("Cmd1 Cmd2 Cmd3"))
            {
                scheduler.Execute(guid, command);
            }
        }