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


C# NancyHost.Dispose方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            var config = new HostConfiguration();
            //config.UrlReservations.CreateAutomatically = true;
            config.RewriteLocalhost = false;

            var bootstrapper = new Bootstrapper();
            host = new NancyHost(bootstrapper, config, baseUri);

            for (int i = 0; ; i++)
            {
                try
                {
                    host.Start();
                    break;
                }
                catch (HttpListenerException ex)
                {
                    // Error 183 happens when the HttpListener fails to listen on the provided Uri
                    if (ex.ErrorCode != 183 || i >= 10) throw;

                    // Close the already running instance
                    try
                    {
                        new WebClient().DownloadString(new Uri(baseUri, "/Close"));
                        System.Threading.Thread.Sleep(40); // Feels like enough :P
                    }
                    catch { }
                }
            }

            Console.WriteLine("Your application is running on: " + baseUri);
            Console.WriteLine("You can type relative URIs to test routes, or enter an empty line to exit");

            var engine = bootstrapper.GetEngine();

            while (true)
            {
                var line = Console.ReadLine();
                if (line == "") break;

                var req = new Request("GET", new Url(baseUri + line));
                var res = engine.HandleRequest(req).Response;

                Console.WriteLine("Response Code: " + res.StatusCode);
                res.Contents(Console.OpenStandardOutput());
                Console.WriteLine();
            }

            ProcModule.KillAllProcs();
            host.Dispose();
        }
开发者ID:hassanselim0,项目名称:MinecraftWebToolkit,代码行数:52,代码来源:Program.cs

示例2: Main

        public static void Main(string[] args)
        {
            Models.Benchmark.Initialize ();
            Models.Configuration.Initialize ();
            Models.Counter.Initialize ();
            Models.Device.Initialize ();
            Models.Project.Initialize ();
            Models.Recipe.Initialize ();
            Models.Revision.Initialize ();
            Models.Run.Initialize ();
            Models.Sample.Initialize ();

            var nancyHost = new NancyHost (new Uri ("http://127.0.0.1:8080/"), new Uri ("http://10.1.12.185:8080/"));

            nancyHost.Start ();

            StaticConfiguration.DisableErrorTraces = false;
            StaticConfiguration.Caching.EnableRuntimeViewUpdates = true;

            Console.WriteLine ("Nancy now listening on http://127.0.0.1:8080/. Press key to stop");

            while (true) {
                if (Console.ReadKey ().Key == ConsoleKey.Enter) {
                    break;
                }

                Thread.Sleep (100);
            }

            nancyHost.Stop ();
            nancyHost.Dispose ();

            Console.WriteLine ("The End;");
        }
开发者ID:honbadger,项目名称:counters-sampler,代码行数:34,代码来源:Main.cs


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