Beispiel #1
0
            /// <summary>
            /// 刷新时间
            /// </summary>
            /// <param name="state"></param>
            private static void refreshTime(object state)
            {
                DateTime now = DateTime.Now;

                Now    = now;
                UtcNow = now.localToUniversalTime();
                timer.Change(TimerInterval = 1000L - now.Millisecond, -1);
#if !Serialize
CHECK:
                long nextSecondTicks = NextSecondTicks;
                if (nextSecondTicks <= Now.Ticks)
                {
                    if (Interlocked.CompareExchange(ref NextSecondTicks, nextSecondTicks + TimeSpan.TicksPerSecond, nextSecondTicks) == nextSecondTicks)
                    {
                        Interlocked.Increment(ref CurrentSeconds);
                        try
                        {
                            AutoCSer.Threading.ThreadPool.CheckExit();
                            for (AutoCSer.Log.File fileLog = AutoCSer.Log.File.Files.End; fileLog != null; fileLog = fileLog.DoubleLinkPrevious)
                            {
                                fileLog.OnTimer();
                            }
                            for (AutoCSer.Net.SocketTimeoutLink.TimerLink timeout = AutoCSer.Net.SocketTimeoutLink.TimerLink.TimeoutEnd; timeout != null; timeout = timeout.DoubleLinkPrevious)
                            {
                                timeout.OnTimer();
                            }
                            for (AutoCSer.Net.TcpServer.ClientCheckTimer timeout = AutoCSer.Net.TcpServer.ClientCheckTimer.TimeoutEnd; timeout != null; timeout = timeout.DoubleLinkPrevious)
                            {
                                timeout.OnTimer();
                            }
                            for (AutoCSer.TimeoutCount timeout = AutoCSer.TimeoutCount.OnTimerLink.End; timeout != null; timeout = timeout.DoubleLinkPrevious)
                            {
                                timeout.OnTimer();
                            }
                            if (IsOnTime)
                            {
                                if (SqlOnTime != null)
                                {
                                    SqlOnTime.OnTimer();
                                }
                                if (WebViewOnTime != null)
                                {
                                    WebViewOnTime.OnTimer();
                                }
                                if (CacheServerOnTime != null)
                                {
                                    CacheServerOnTime.OnTimer();
                                }
                                if (TcpSimpleServerOnTime != null)
                                {
                                    TcpSimpleServerOnTime.OnTimer();
                                }
                            }

                            AutoCSer.Threading.TimerTask.Default.OnTimer(Now);
                            if (Date.OnTime != null)
                            {
                                Date.OnTime();
                            }
                        }
                        catch (Exception error)
                        {
                            AutoCSer.Log.Pub.Log.Add(AutoCSer.Log.LogType.Error, error);
                        }
                    }
                    goto CHECK;
                }
#endif
            }
Beispiel #2
0
            /// <summary>
            /// 刷新时间
            /// </summary>
            /// <param name="state"></param>
            private static void refreshTime(object state)
            {
                DateTime now = DateTime.Now;

                Now    = now;
                UtcNow = now.localToUniversalTime();
                timer.Change(TimerInterval = 1000L - now.Millisecond, -1);
#if !Serialize
CHECK:
                long nextSecondTicks = NextSecondTicks;
                if (nextSecondTicks <= Now.Ticks)
                {
                    if (Interlocked.CompareExchange(ref NextSecondTicks, nextSecondTicks + SecondTicks, nextSecondTicks) == nextSecondTicks)
                    {
                        Interlocked.Increment(ref CurrentSeconds);
                        try
                        {
                            AutoCSer.Threading.ThreadPool.CheckExit();
                            if ((Flag & OnTimeFlag.LogFile) != 0)
                            {
                                for (AutoCSer.Log.File fileLog = AutoCSer.Log.File.Files.End; fileLog != null; fileLog = fileLog.DoubleLinkPrevious)
                                {
                                    fileLog.OnTimer();
                                }
                            }
                            if ((Flag & OnTimeFlag.TcpServerSocketTimerLink) != 0)
                            {
                                for (AutoCSer.Net.SocketTimeoutLink.TimerLink timeout = AutoCSer.Net.SocketTimeoutLink.TimerLink.TimeoutEnd; timeout != null; timeout = timeout.DoubleLinkPrevious)
                                {
                                    timeout.OnTimer();
                                }
                            }
                            if ((Flag & OnTimeFlag.TcpClientCheckTimer) != 0)
                            {
                                for (AutoCSer.Net.TcpServer.ClientCheckTimer timeout = AutoCSer.Net.TcpServer.ClientCheckTimer.TimeoutEnd; timeout != null; timeout = timeout.DoubleLinkPrevious)
                                {
                                    timeout.OnTimer();
                                }
                            }
                            if ((Flag & (OnTimeFlag.TcpSimpleClientCheckTimer)) != 0)
                            {
                                TcpSimpleServerOnTime(Flag);
                            }

                            if ((Flag & (OnTimeFlag.CacheFile | OnTimeFlag.CacheDistributionTimeout | OnTimeFlag.CacheTimeout)) != 0)
                            {
                                CacheOnTime(Flag);
                            }
                            if ((Flag & OnTimeFlag.SqlCountMember) != 0)
                            {
                                SqlOnTime(Flag);
                            }
                            if ((Flag & (OnTimeFlag.HttpSession | OnTimeFlag.CreateFlieTimeoutWatcher)) != 0)
                            {
                                WebViewOnTime(Flag);
                            }

                            AutoCSer.Threading.TimerTask.Default.OnTimer(Now);
                            if ((Flag & OnTimeFlag.TcpRegister) != 0)
                            {
                                for (AutoCSer.Net.TcpRegister.Server server = AutoCSer.Net.TcpRegister.Server.ServerEnd; server != null; server = server.DoubleLinkPrevious)
                                {
                                    server.OnTimer();
                                }
                            }
                            if (OnTime != null)
                            {
                                OnTime();
                            }
                        }
                        catch (Exception error)
                        {
                            AutoCSer.Log.Pub.Log.Add(AutoCSer.Log.LogType.Error, error);
                        }
                    }
                    goto CHECK;
                }
#endif
            }