protected override void OnStart(string[] args)
        {
            var responder = new HttpListenerResponder();

            _listener = new DistributingHttpListener("http://localhost:8080/");
            _listener.AddResponder(responder);
            _listener.Start();
        }
示例#2
0
        static void Main()
        {
            var responder = new HttpListenerResponder();

            using (var listener = new DistributingHttpListener("http://localhost:8080/"))
            {
                listener.AddResponder(responder);
                listener.Start();

                Console.WriteLine("Press Enter or Escape to stop.");
                for (;;)
                {
                    ConsoleKeyInfo key = Console.ReadKey(intercept: true);
                    if (key.Key == ConsoleKey.Enter || key.Key == ConsoleKey.Escape)
                    {
                        break;
                    }
                }

                listener.Stop();
            }
        }