示例#1
0
        public void Start()
        {
            CatConfig.Init(AppConfig.CatDomain, AppConfig.CatEnable, AppConfig.CatServer);

            MapArea.RegisterMapArea();

            if (AppConfig.HttpPort > 0)
            {
                Task.Factory.StartNew(() =>
                {
                    _webApp = new WebApp();
                    _webApp.Start(AppConfig.HttpPort);
                }, TaskCreationOptions.LongRunning)
                .ContinueWith(t =>
                {
                    if (!t.IsFaulted)
                    {
                        return;
                    }
                    LogInfoWriter.GetInstance().Error("TcpApp start error", t.Exception);
                    if (t.Exception != null)
                    {
                        throw t.Exception;
                    }
                });
            }

            if (AppConfig.TcpPort > 0)
            {
                Task.Factory.StartNew(() =>
                {
                    _tcpApp = new TcpApp();
                    _tcpApp.Start(AppConfig.TcpPort);
                }, TaskCreationOptions.LongRunning)
                .ContinueWith(t =>
                {
                    if (!t.IsFaulted)
                    {
                        return;
                    }
                    LogInfoWriter.GetInstance().Error("TcpApp start error", t.Exception);
                    if (t.Exception != null)
                    {
                        throw t.Exception;
                    }
                });
            }
        }