public Controller(MessagingScheduler scheduler) { messaging = scheduler; messaging.CommandStatusChanged += Notify; background = new BackgroundThreadScheduler(messaging); views = new List <IView>(); }
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); }
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); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var view = new ClientGui(); var view2 = new ClientGui(); var view3 = new FileView("output.txt"); var scheduler = new MessagingScheduler(new SimpleScheduler()); var controller = new SessionOnlyController(scheduler); var controller2 = new Controller(scheduler); controller.AddView(view); controller2.AddView(view2); controller2.AddView(view3); view2.Show(); Application.Run(view); view3.Dispose(); }
public SessionOnlyController(MessagingScheduler scheduler) : base(scheduler) { }