예제 #1
0
        /// <summary>
        /// 运行心跳
        /// </summary>
        public override void Run()
        {
            heartInfo.Heart = AppDomainHelper.CreateHeart(heartInfo.HeartDomain, heartInfo.Name, heartInfo.Name + "." + AppDomainHelper.HeartClassName);

            if (heartInfo.Heart != null)
            {
                if (heartInfo.heartTimer == null)
                {
                    heartInfo.heartTimer = new Timer(heartInfo.runningHeart.DoAction, null, 0, (int)heartInfo.SpanInfo.Span.TotalMilliseconds);
                }
                else
                {
                    heartInfo.heartTimer.Change(0, (int)heartInfo.SpanInfo.Span.TotalMilliseconds);
                }

                heartInfo.heartState = heartInfo.runningHeart;
            }
        }
예제 #2
0
        internal static OnceServer CreateOnceServerByKey(string key)
        {
            OnceServer os = null;

            HeartServerInfo hsi = HeartServerDirMonitor.Single[key];

            if (hsi != null)
            {
                DirectoryHelper.DirectoryCopy(hsi.DirPath, OnceDirPath + hsi.Name);
                os = new OnceServer();

                os.Domain = AppDomainHelper.CreateHeartServerAppDomain(OnceDirPath + hsi.Name, hsi.Name);

                if (os.Domain != null)
                {
                    os.HeartServer = AppDomainHelper.CreateHeart(os.Domain, hsi.Name, hsi.Name + "." + AppDomainHelper.HeartClassName);
                }
            }

            return(os);
        }