当前位置: 首页>>代码示例>>C#>>正文


C# Waiter.PlaceDodgyOrder方法代码示例

本文整理汇总了C#中Waiter.PlaceDodgyOrder方法的典型用法代码示例。如果您正苦于以下问题:C# Waiter.PlaceDodgyOrder方法的具体用法?C# Waiter.PlaceDodgyOrder怎么用?C# Waiter.PlaceDodgyOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Waiter的用法示例。


在下文中一共展示了Waiter.PlaceDodgyOrder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var d = new Dispatcher();
            var midgetHouse = new MidgetHouse(d);
            d.Subscribe<OrderPlaced>(midgetHouse);
            d.Subscribe<DodgyOrderPlaced>(midgetHouse);
            var manager = new Manager();
            var cashier = new Cashier(d);
            var ass = new AssMan(d);

            var cookDispatcher = new SmartDispatcher<CookFood>();
            var cookTtlGate = new TimeToLiveGate<CookFood>(cookDispatcher);
            var cookQueudHandler = new QueuedHandler<CookFood>(cookTtlGate, "cook ttl gate");
            var cookLimiter = new Limiter<CookFood>(cookQueudHandler);
            //var cookScrewsUp = new ScrewsUp<CookFood>(cookLimiter);

            var alarmClock = new AlarmClock(d);

            var messageMonitor = new MessageMonitor(d);
            var fmm = new FilePerOrderMonitor(d);

            d.Subscribe(alarmClock);
            d.Subscribe(cookLimiter);
            d.Subscribe(ass);
            d.Subscribe(cashier);
            d.Subscribe(manager);
            d.Subscribe<OrderPlaced>(messageMonitor);
            d.Subscribe<DodgyOrderPlaced>(messageMonitor);
            d.Subscribe<OrderPlaced>(fmm);
            d.Subscribe<DodgyOrderPlaced>(fmm);

            var cookQueudHandler1 = new QueuedHandler<CookFood>(new Cook(d, 10000), "c1");
            cookDispatcher.AddHandler(cookQueudHandler1);
            var cookQueudHandler2 = new QueuedHandler<CookFood>(new Cook(d, 5000), "c2");
            cookDispatcher.AddHandler(cookQueudHandler2);
            var cookQueudHandler3 = new QueuedHandler<CookFood>(new Cook(d, 100), "c3");
            cookDispatcher.AddHandler(cookQueudHandler3);

            var queueMonitor = new QueueMonitor(new IAmMonitored[] {cookQueudHandler1, cookQueudHandler2, cookQueudHandler3, cookQueudHandler,d.QueudHandler});

            //Cook cook = new Cook(ass);
            var waiter = new Waiter(d);

            cookQueudHandler1.Start();
            cookQueudHandler2.Start();
            cookQueudHandler3.Start();
            cookQueudHandler.Start();
            d.Start();
            alarmClock.Start();
            queueMonitor.Start();

            new Thread(TryPay).Start(cashier);

            Random r = new Random();
            for (int i = 0; i < 500; i++)
            {
                Guid orderNumber;
                if (r.Next()%2 == 0)
                {
                    orderNumber = waiter.PlaceDodgyOrder(new[] {Tuple.Create("Burger", 1)}, 15);

                }
                else
                {
                    orderNumber = waiter.PlaceOrder(new[] { Tuple.Create("Burger", 1) }, 15);
                }

                if(i > 2)Thread.Sleep(2000);

                orders.TryAdd(orderNumber, null);
            }
            //var orderNumber = waiter.PlaceOrder(new[] {Tuple.Create("Burger", 1)}, 15);
            //cashier.PayForOrder(orderNumber);
            Console.ReadLine();
        }
开发者ID:simonlaroche,项目名称:DumpingGrounds,代码行数:75,代码来源:Program.cs


注:本文中的Waiter.PlaceDodgyOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。