コード例 #1
0
        /// <summary>服务停止</summary>
        /// <remarks>
        /// 安装Windows服务后,服务停止会执行该方法。
        /// 控制台菜单按5进入循环调试,任意键结束时也会执行该方法。
        /// </remarks>
        protected override void StopWork(String reason)
        {
            base.StopWork(reason);

            _Server.TryDispose();
            _Server = null;
        }
コード例 #2
0
        private void Init()
        {
            var sc = _Server;

            if (sc == null)
            {
                var set = Setting.Current;

                sc = new RpcServer(set.Port);
                var ns = sc.EnsureCreate() as NetServer;
                sc.ShowError = true;

                if (Setting.Current.Debug)
                {
                    sc.Log = XTrace.Log;
                    ns.Log = XTrace.Log;
#if DEBUG
                    ns.LogSend    = true;
                    ns.LogReceive = true;
                    sc.EncoderLog = XTrace.Log;
#endif
                }

                // 注册服务
                sc.Register <SyncService>();
                sc.Start();

                _Server = sc;
            }
        }