Beispiel #1
0
 /// <summary>
 /// 初始化服务
 /// </summary>
 /// <returns></returns>
 virtual public void InitInstance(string[] args)
 {
     //修改引用TITLE
     if (SvrCommCfg.Instance.ServerInfo.m_Name == "")
     {
         SvLogger.Error("ServerName cannot be empty.");
     }
     SvLogger.Info("ServerName = {0}.", SvrCommCfg.Instance.ServerInfo.m_Name);
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         Process processes = Process.GetCurrentProcess();
         PInvoker.SetConsoleTitle(GetAssemblyName() + " - " + processes.Id);
         SvrCommCfg.Instance.ProcessID = processes.Id;
     }
 }
Beispiel #2
0
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="service">服务类</param>
        /// <param name="args">服务参数</param>
        public BasicServiceRunner(BasicService service, string[] args)
        {
            #region 去掉关闭菜单

            try
            {
                int  hwnd  = (int)System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
                int  hmenu = PInvoker.GetSystemMenu(hwnd, false);
                bool bsucc = PInvoker.RemoveMenu(hmenu, 0xF060, 0);
            }
            catch
            {
            }

            #endregion

            #region 初始化

            try
            {
                _Service = service;
                _Service.InitInstance(args);
                _Service.IsRunning = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("Abnormal Application Termination :{0}\r\nStackTrace : \r\n{1}", e.Message, e.StackTrace);
                try
                {
                    HTEventLog.InitFileLog(@"ServerEvents.log");
                    HTEventLog.SaveLog(HTEventLog.LogTypeEnum.错误, string.Format("Abnormal Application Termination : {0}\r\nStackTrace : \r\n{1}", e.Message, e.StackTrace), _Service.GetAssemblyName());
                }
                catch
                {
                }
                //Network.NetworkManager.Instance.StopRunNetworkUpdate();
                _Service.IsRunning = false;
                return;
            }

            #endregion
        }