Пример #1
0
        public void Start()
        {
            try
            {
                ConsoleSampleServer().Wait();
                Console.WriteLine("Server started. Press any key to exit...");
            }
            catch (Exception ex)
            {
                Utils.Trace("ServiceResultException:" + ex.Message);
                Console.WriteLine("Exception: {0}", ex.Message);
            }

            //try
            //{
            //    Console.ReadKey(true);
            //}
            //catch
            //{
            //    // wait forever if there is no console
            //    Thread.Sleep(Timeout.Infinite);
            //}

            if (server != null)
            {
                Console.WriteLine("Server stopped. Waiting for exit...");

                server.Dispose();
                server = null;

                status.Wait();
            }
        }