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


C# Host.Stop方法代码示例

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


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

示例1: should_call_initializer_methods_in_right_order

        public void should_call_initializer_methods_in_right_order()
        {
            var counter = new Counter();
            var bus = new TestBus();
            bus.Starting += () => counter.Increment();
            bus.Started += () => counter.Increment();
            bus.Stopping += () => counter.Increment();
            bus.Stopped += () => counter.Increment();
            var testHostInitializer = new TestHostInitializer(counter);
            var host = new Host();
            var container = host.ContainerFactory.Invoke();
            host.ContainerFactory = () =>
            {
                container.Configure(x =>
                {
                    x.ForSingletonOf<IBus>().Use(bus);
                    x.ForSingletonOf<HostInitializer>().Add(testHostInitializer);
                });
                return container;
            };

            host.Start();
            host.Stop();

            testHostInitializer.CapturedContainer.ShouldEqual(container);
            testHostInitializer.ConfigureContainerCounterValue.ShouldEqual(0);
            testHostInitializer.BeforeStartCounterValue.ShouldEqual(0);
            testHostInitializer.AfterStartCounterValue.ShouldEqual(2);
            testHostInitializer.BeforeStopCounterValue.ShouldEqual(2);
            testHostInitializer.AfterStopCounterValue.ShouldEqual(4);
        }
开发者ID:Abc-Arbitrage,项目名称:Zebus.TinyHost,代码行数:31,代码来源:HostTests.cs

示例2: CrashOnRunTest

 public void CrashOnRunTest()
 {
     using (Host test = new Host())
     {
         PayloadDescription desc = new PayloadDescription();
         string assembly = typeof(TestService.TestService).Assembly.CodeBase;
         desc.AssemblyFullName = assembly;
         desc.Class = typeof(TestService.TestService).FullName;
         desc.Parameter = "AsyncRaiseOnRun";
         Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
         using (TestTracer tracer = TestTracer.FromDomain(test.Domain))
         {
             test.Start();
             Thread.Sleep(500);
             Assert.AreEqual("StartWithParam", tracer.Pop(), "TestMethod.Start should have been called");
             Assert.AreEqual("Default", tracer.Pop(), "Bad test parameter");
             Assert.AreEqual("RaisedException", tracer.Pop(), "Should have raised an exception");
             test.Stop();
             Assert.AreEqual("Stop", tracer.Pop(), "Should have raised an exception");
             Assert.IsTrue(tracer.IsEmpty, "No other events should have occured");
         }
     }
 }
开发者ID:dupdob,项目名称:SHON,代码行数:23,代码来源:HostTest.cs

示例3: AlternateTest

        public void AlternateTest()
        {
            using (Host test = new Host())
            {
                PayloadDescription desc = new PayloadDescription();
                string assembly = typeof(TestService.TestService).Assembly.CodeBase;
                desc.AssemblyFullName = assembly;
                desc.Class = typeof(TestService.TestService).FullName;
                desc.ConfigurationFile = "AltShon.TestService.config";
                Assert.IsTrue(test.Initialize(desc), "Initialize must succeed");
                using (TestTracer tracer = TestTracer.FromDomain(test.Domain))
                {
                    test.Start();

                    Assert.AreEqual("Start", tracer.Pop(), "TestMethod.Start should have been called");

                    Assert.AreEqual("Alt", tracer.Pop(), "Bad test parameter");
                    test.Stop();

                    Assert.AreEqual("Stop", tracer.Pop(), "TestMethod.Stop should have been called");
                    Assert.IsTrue(tracer.IsEmpty, "No other events should have occured");
                }
            }
        }
开发者ID:dupdob,项目名称:SHON,代码行数:24,代码来源:HostTest.cs

示例4: RunAsConsole

        private static void RunAsConsole()
        {
            string title = string.Format(CultureInfo.CurrentCulture, "StealFocus Forecast Console. Version {0}", typeof(Program).Assembly.GetName().Version);
            OutputVersionAndCopyrightMessage(title);
            Host host = new Host();
            host.Start();

            // Write with the console (and not via the logger) to guarantee this message
            // is displayed to the user (in case the logger is misconfigured).
            System.Console.WriteLine("Press return to stop the workers.");
            System.Console.ReadLine();
            host.Stop();
            host.WaitForWorkersToStop();
        }
开发者ID:StealFocus,项目名称:Forecast,代码行数:14,代码来源:Program.cs


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