コード例 #1
0
        public string DateExtended(int value)
        {
            var clientDelta  = MTProtoService.Current.ClientTicksDelta;
            var utc0SecsLong = value * 4294967296 - clientDelta;
            var utc0SecsInt  = utc0SecsLong / 4294967296.0;
            var dateTime     = Utils.UnixTimestampToDateTime(utc0SecsInt);

            var cultureInfo      = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
            var shortTimePattern = Utils.GetShortTimePattern(ref cultureInfo);

            //Today
            if (dateTime.Date == System.DateTime.Now.Date)
            {
                //TimeLabel.Text = dateTime.ToString(string.Format("{0}", shortTimePattern), cultureInfo);
                return(ShortTime.Format(dateTime));
            }

            //Week
            if (dateTime.Date.AddDays(6) >= System.DateTime.Now.Date)
            {
                if (_formatterCache.TryGetValue("dayofweek.abbreviated", out DateTimeFormatter formatter) == false)
                {
                    formatter = new DateTimeFormatter("dayofweek.abbreviated", Windows.System.UserProfile.GlobalizationPreferences.Languages);
                    _formatterCache["dayofweek.abbreviated"] = formatter;
                }

                return(formatter.Format(dateTime));
            }

            //Long long time ago
            //TimeLabel.Text = dateTime.ToString(string.Format("d.MM.yyyy", shortTimePattern), cultureInfo);
            return(ShortDate.Format(dateTime));
        }
コード例 #2
0
        public string BannedUntil(long date)
        {
            var banned = Utils.UnixTimestampToDateTime(date);

            return(ShortDate.Format(banned) + ", " + ShortTime.Format(banned));

            //try
            //{
            //    date *= 1000;
            //    var rightNow = System.DateTime.Now;
            //    var year = rightNow.Year;
            //    var banned = Utils.UnixTimestampToDateTime(date);
            //    int dateYear = banned.Year;

            //    if (year == dateYear)
            //    {
            //        //formatterBannedUntil = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntil24H", R.string.formatterBannedUntil24H) : getStringInternal("formatterBannedUntil12H", R.string.formatterBannedUntil12H), is24HourFormat ? "MMM dd yyyy, HH:mm" : "MMM dd yyyy, h:mm a");
            //        //formatterBannedUntilThisYear = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntilThisYear24H", R.string.formatterBannedUntilThisYear24H) : getStringInternal("formatterBannedUntilThisYear12H", R.string.formatterBannedUntilThisYear12H), is24HourFormat ? "MMM dd, HH:mm" : "MMM dd, h:mm a");

            //        return getInstance().formatterBannedUntilThisYear.format(new Date(date));
            //    }
            //    else
            //    {
            //        return getInstance().formatterBannedUntil.format(new Date(date));
            //    }
            //}
            //catch (Exception e)
            //{
            //    //FileLog.e(e);
            //}

            //return "LOC_ERR";
        }
コード例 #3
0
        public void Initialize()
        {
            if (this.taskDictionary.Count < 2)
            {
                throw new Exception("Count of StartHour must >= 2 !");
            }
            List <ShortTime> list = new List <ShortTime>();

            foreach (ShortTime time in this.taskDictionary.Keys)
            {
                list.Add(time);
            }
            list.Sort();
            this.taskTimeCircle = new Circle <ShortTime>(list);
            ShortTime time2 = new ShortTime(DateTime.Now);

            if ((time2.CompareTo(this.taskTimeCircle.Tail) >= 0) || (time2.CompareTo(this.taskTimeCircle.Header) < 0))
            {
                this.taskTimeCircle.SetCurrent(this.taskTimeCircle.Tail);
            }
            else
            {
                this.taskTimeCircle.SetCurrent(this.taskTimeCircle.Header);
                while (time2.CompareTo(this.taskTimeCircle.PeekNext()) >= 0)
                {
                    this.taskTimeCircle.MoveNext();
                }
            }
            this.agileCycleEngine = new AgileCycleEngine(this);
            this.agileCycleEngine.DetectSpanInSecs = 1;
            this.agileCycleEngine.Start();
        }
コード例 #4
0
        /// <summary>
        /// Creates a <see cref="LogEventPublisherInternal"/>.
        /// </summary>
        /// <param name="attributes"></param>
        /// <param name="owner">the owner of the log messages.</param>
        /// <param name="publisher">the publisher that is used to raise messages</param>
        /// <param name="logger">the callback for all new messages that are generated.</param>
        /// <param name="stackTraceDepth"></param>
        /// <param name="messagesPerSecond"></param>
        /// <param name="burstLimit"></param>
        internal LogEventPublisherInternal(LogMessageAttributes attributes, LogEventPublisherDetails owner, LogPublisherInternal publisher, LoggerInternal logger, int stackTraceDepth, double messagesPerSecond, int burstLimit)
        {
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }
            if (publisher == null)
            {
                throw new ArgumentNullException(nameof(publisher));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            m_attributes = attributes;
            var supression = new LogSuppressionEngine(messagesPerSecond, burstLimit);

            m_owner            = owner;
            m_logger           = logger;
            m_stackTraceDepth  = 0;
            m_supressionEngine = supression;
            m_publisher        = publisher;
            m_stackTraceDepth  = stackTraceDepth;
            m_suppressionMessageNextPublishTime = ShortTime.Now;
        }
コード例 #5
0
        /// <summary>
        /// Contains 目标时刻是否在时间范围内
        /// </summary>       
        public bool Contains(ShortTime target)
        {
            bool bStart = this.shortTimeStart.CompareTo(target) <= 0;
            bool bEnd = this.shortTimeEnd.CompareTo(target) >= 0;

            return bStart && bEnd;
        }
コード例 #6
0
ファイル: Frame.cs プロジェクト: xj0229/gsf
 /// <summary>
 /// Constructs a new <see cref="Frame"/> given the specified parameters.
 /// </summary>
 /// <param name="timestamp">Timestamp, in ticks, for this <see cref="Frame"/>.</param>
 /// <param name="measurements">Initial set of measurements to load into the <see cref="Frame"/>, if any.</param>
 public Frame(Ticks timestamp, IDictionary <MeasurementKey, IMeasurement> measurements)
 {
     m_timestamp          = timestamp;
     m_lifespan           = ShortTime.Now;
     m_measurements       = new ConcurrentDictionary <MeasurementKey, IMeasurement>(measurements);
     m_sortedMeasurements = -1;
 }
コード例 #7
0
        private static void MonitorLowPriority()
        {
            ShortTime lastTime = ShortTime.Now;

            while (true)
            {
                try
                {
                    Thread.Sleep(10);
                    ShortTime currentTime = ShortTime.Now;

                    long   sleepDelta        = (long)lastTime.ElapsedTicks(currentTime);
                    long   additionalDelay   = sleepDelta - 100 * TimeSpan.TicksPerMillisecond;
                    double additionalDelayMS = additionalDelay / (double)TimeSpan.TicksPerMillisecond;

                    if (additionalDelayMS > 1000)
                    {
                        LogLarge.Publish(additionalDelayMS.ToString() + " ms (Normal Priority)");
                    }
                    else if (additionalDelayMS > 500)
                    {
                        LogMedium.Publish(additionalDelayMS.ToString() + " ms (Normal Priority)");
                    }

                    Interlocked.Increment(ref s_lowProcessCount);

                    lastTime = currentTime;
                }
                catch (Exception ex)
                {
                    Log.Publish(MessageLevel.Warning, MessageFlags.BugReport, "Unexpected Exception Caught", null, null, ex);
                    Thread.Sleep(1000);
                }
            }
        }
コード例 #8
0
        public string DateExtended(int value)
        {
            var dateTime = Utils.UnixTimestampToDateTime(value);

            //Today
            if (dateTime.Date == System.DateTime.Now.Date)
            {
                //TimeLabel.Text = dateTime.ToString(string.Format("{0}", shortTimePattern), cultureInfo);
                return(ShortTime.Format(dateTime));
            }

            //Week
            if (dateTime.Date.AddDays(6) >= System.DateTime.Now.Date)
            {
                if (_formatterCache.TryGetValue("dayofweek.abbreviated", out DateTimeFormatter formatter) == false)
                {
                    //var region = new GeographicRegion();
                    //var code = region.CodeTwoLetter;

                    formatter = new DateTimeFormatter("dayofweek.abbreviated", GlobalizationPreferences.Languages, GlobalizationPreferences.HomeGeographicRegion, GlobalizationPreferences.Calendars.FirstOrDefault(), GlobalizationPreferences.Clocks.FirstOrDefault());
                    _formatterCache["dayofweek.abbreviated"] = formatter;
                }

                return(formatter.Format(dateTime));
            }

            //Long long time ago
            //TimeLabel.Text = dateTime.ToString(string.Format("d.MM.yyyy", shortTimePattern), cultureInfo);
            return(ShortDate.Format(dateTime));
        }
コード例 #9
0
 private static void Reset()
 {
     Interlocked.Exchange(ref s_currentTime, DateTime.UtcNow.Ticks);
     s_currentTimeSetTime = ShortTime.Now;
     Interlocked.Exchange(ref s_highProcessCount, 0);
     Interlocked.Exchange(ref s_normalProcessCount, 0);
     Interlocked.Exchange(ref s_lowProcessCount, 0);
 }
コード例 #10
0
 protected BasePhaseIncreaseAccesser()
 {
     this.currentRoundStartTime = DateTime.Now;
     this.dayOriginTime         = new ShortTime(0, 0, 0);
     this.manyDaysInOneRound    = 1;
     this.todayIsFirstDay       = false;
     this.sourceTokenList       = new List <TSourceToken>();
 }
コード例 #11
0
ファイル: ThreadPoolMonitor.cs プロジェクト: xj0229/gsf
 private static void LoadingAdjustedTimestamp_OnHighLoad()
 {
     if (s_lastResetTime.ElapsedSeconds() > 10)
     {
         s_lastResetTime = ShortTime.Now;
         MonitorThreads();
     }
 }
コード例 #12
0
        /// <summary>
        /// Raises a log message with the provided data.
        /// </summary>
        /// <param name="overriddenAttributes">attributes to use with this message</param>
        /// <param name="message"></param>
        /// <param name="details">A long text field with the details of the message.</param>
        /// <param name="exception">An exception object if one is provided.</param>
        /// <param name="initialStackMessage"></param>
        /// <param name="initialStackTrace"></param>
        public void Publish(LogMessageAttributes?overriddenAttributes, string message, string details, Exception exception, LogStackMessages initialStackMessage, LogStackTrace initialStackTrace)
        {
            if (Logger.ShouldSuppressLogMessages)
            {
                return;
            }

            LogMessageAttributes attributes = overriddenAttributes ?? m_attributes;

            if (!m_publisher.HasSubscribers(attributes))
            {
                return;
            }

            if (message == null)
            {
                message = string.Empty;
            }
            if (details == null)
            {
                details = string.Empty;
            }

            var suppressionFlags = m_supressionEngine.IncrementPublishCount();

            if (suppressionFlags != MessageSuppression.None)
            {
                m_messagesSuppressed++;

                if (ShouldRaiseMessageSupressionNotifications && m_suppressionMessageNextPublishTime <= ShortTime.Now)
                {
                    m_suppressionMessageNextPublishTime = ShortTime.Now.AddSeconds(10);
                    MessageSuppressionIndication.Publish($"Message Suppression Is Occurring To: '{ m_owner.TypeData.TypeName }' {m_messagesSuppressed.ToString()} total messages have been suppressed.", m_owner.ToString());
                }

                attributes += suppressionFlags;
                if (!m_publisher.HasSubscribers(attributes))
                {
                    return;
                }
            }

            LogStackMessages currentStackMessages = Logger.GetStackMessages();
            LogStackTrace    currentStackTrace    = LogStackTrace.Empty;

            if (m_stackTraceDepth > 0)
            {
                currentStackTrace = new LogStackTrace(true, 2, m_stackTraceDepth);
            }
            else if (exception != null || attributes.Level >= MessageLevel.Error)
            {
                currentStackTrace = new LogStackTrace(true, 2, 10);
            }

            var logMessage = new LogMessage(m_owner, initialStackMessage, initialStackTrace, currentStackMessages, currentStackTrace, attributes, message, details, exception);

            m_logger.OnNewMessage(logMessage, m_publisher);
        }
コード例 #13
0
        /// <summary>
        /// 任务构造函数
        /// </summary>
        /// <param name="type">任务执行间隔</param>
        /// <param name="time">执行时间</param>
        /// <param name="taskName">任务名称</param>
        protected Timing(TimingTaskType type, ShortTime time, string taskName)
        {
            TimingTaskType = type;
            ExcuteTime = time;
            TimingTaskExcuter = this;
            _taskName = taskName;

            Log.General(_taskName + ":Timing加载完毕并开始执行");
        }
コード例 #14
0
        /// <summary>
        /// Open property window.
        /// </summary>
        private void MenuItem_Properties_Click(object sender, RoutedEventArgs e)
        {
            string    filePath = this.mediaElement.Source.LocalPath;
            string    fileName = new FileInfo(filePath).Name;
            MediaInfo mi       = this.GetPlayedMediaInfo();
            string    time     = ShortTime.TimeToString(this.mediaElement.NaturalDuration.TimeSpan);

            this.LibraryManager.ShowProperties(fileName, filePath, mi.MediaType, time, mi.Resolution);
        }
コード例 #15
0
        public ShortTimeScope(ShortTime first, ShortTime later)
        {
            this.shortTimeStart = first;
            this.shortTimeEnd = later;

            if (first.CompareTo(later) >= 0)
            {
                throw new Exception("the parameter later must be greatter than first!");
            }
        }        
コード例 #16
0
ファイル: ChannelFrameBase.cs プロジェクト: xj0229/gsf
        private IMeasurement m_lastSortedMeasurement;                                        // Last measurement sorted into this frame             (IFrame.LastSortedMeasurement)

        #endregion

        #region [ Constructors ]

        /// <summary>
        /// Creates a new <see cref="ChannelFrameBase{T}"/> from specified parameters.
        /// </summary>
        /// <param name="idCode">The ID code of this <see cref="ChannelFrameBase{T}"/>.</param>
        /// <param name="cells">The reference to the collection of cells for this <see cref="ChannelFrameBase{T}"/>.</param>
        /// <param name="timestamp">The exact timestamp, in <see cref="Ticks"/>, of the data represented by this <see cref="ChannelFrameBase{T}"/>.</param>
        protected ChannelFrameBase(ushort idCode, IChannelCellCollection <T> cells, Ticks timestamp)
        {
            m_idCode             = idCode;
            m_cells              = cells;
            m_timestamp          = timestamp;
            m_lifespan           = ShortTime.Now;
            m_trustHeaderLength  = true;
            m_validateCheckSum   = true;
            m_measurements       = new ConcurrentDictionary <MeasurementKey, IMeasurement>();
            m_sortedMeasurements = -1;
        }
コード例 #17
0
ファイル: ChannelFrameBase.cs プロジェクト: xj0229/gsf
 /// <summary>
 /// Creates a new <see cref="ChannelFrameBase{T}"/> from serialization parameters.
 /// </summary>
 /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
 /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
 protected ChannelFrameBase(SerializationInfo info, StreamingContext context)
 {
     // Deserialize key frame elements...
     m_idCode             = info.GetUInt16("idCode");
     m_cells              = (IChannelCellCollection <T>)info.GetValue("cells", typeof(IChannelCellCollection <T>));
     m_timestamp          = info.GetInt64("timestamp");
     m_lifespan           = ShortTime.Now;
     m_trustHeaderLength  = true;
     m_validateCheckSum   = true;
     m_measurements       = new ConcurrentDictionary <MeasurementKey, IMeasurement>();
     m_sortedMeasurements = -1;
 }
コード例 #18
0
        public bool IsOnTime(int checkSpanSeconds, DateTime now)
        {
            TimeSpan span = (TimeSpan)(now - this.lastRightTime);

            if (span.TotalMilliseconds < ((checkSpanSeconds * 0x3e8) * 2))
            {
                return(false);
            }
            bool flag = false;

            switch (this.timingTaskType)
            {
            case global::CJBasic.Threading.Timers.TimingTaskType.PerHour:
                flag = new ShortTime(now.Hour, this.excuteTime.Minute, this.excuteTime.Second).IsOnTime(now, checkSpanSeconds);
                if (!flag)
                {
                    flag = new ShortTime(now.AddHours(1.0).Hour, this.excuteTime.Minute, this.excuteTime.Second).IsOnTime(now, checkSpanSeconds);
                }
                if (!flag)
                {
                    flag = new ShortTime(now.AddHours(-1.0).Hour, this.excuteTime.Minute, this.excuteTime.Second).IsOnTime(now, checkSpanSeconds);
                }
                break;

            case global::CJBasic.Threading.Timers.TimingTaskType.PerDay:
                flag = this.excuteTime.IsOnTime(now, checkSpanSeconds);
                break;

            case global::CJBasic.Threading.Timers.TimingTaskType.PerWeek:
                if (now.DayOfWeek == this.dayOfWeek)
                {
                    flag = this.excuteTime.IsOnTime(now, checkSpanSeconds);
                    break;
                }
                flag = false;
                break;

            case global::CJBasic.Threading.Timers.TimingTaskType.PerMonth:
                if (now.Day == this.day)
                {
                    flag = this.excuteTime.IsOnTime(now, checkSpanSeconds);
                    break;
                }
                flag = false;
                break;
            }
            if (flag)
            {
                this.lastRightTime = now;
            }
            return(flag);
        }
コード例 #19
0
ファイル: TimingTask.cs プロジェクト: puxu1989/PXLib
        public bool IsOnTime(int checkSpanSeconds, DateTime now)
        {
            bool result;

            //如果lastRightTime与当前时间的差值2倍的扫描间隔以内,则将认为当前时间不符合条件
            if ((now - this.lastRightTime).TotalMilliseconds < (double)(checkSpanSeconds * 1000 * 2))
            {
                result = false;
            }
            else
            {
                bool flag = false;
                switch (this.timingTaskType)
                {
                case TimingTaskType.PerHour:
                {
                    ShortTime shortTime = new ShortTime(now.Hour, this.excuteTime.Minute, this.excuteTime.Second);
                    flag = shortTime.IsOnTime(now, checkSpanSeconds);
                    if (!flag)
                    {
                        ShortTime shortTime2 = new ShortTime(now.AddHours(1.0).Hour, this.excuteTime.Minute, this.excuteTime.Second);
                        flag = shortTime2.IsOnTime(now, checkSpanSeconds);
                    }
                    if (!flag)
                    {
                        ShortTime shortTime3 = new ShortTime(now.AddHours(-1.0).Hour, this.excuteTime.Minute, this.excuteTime.Second);
                        flag = shortTime3.IsOnTime(now, checkSpanSeconds);
                    }
                    break;
                }

                case TimingTaskType.PerDay:
                    flag = this.excuteTime.IsOnTime(now, checkSpanSeconds);
                    break;

                case TimingTaskType.PerWeek:
                    flag = (now.DayOfWeek == this.dayOfWeek && this.excuteTime.IsOnTime(now, checkSpanSeconds));
                    break;

                case TimingTaskType.PerMonth:
                    flag = (now.Day == this.day && this.excuteTime.IsOnTime(now, checkSpanSeconds));
                    break;
                }
                if (flag)
                {
                    this.lastRightTime = now;
                }
                result = flag;
            }
            return(result);
        }
コード例 #20
0
        private void timer_Tick(object sender, EventArgs e)
        {
            this.Refresh(); // do paint
            if (onTop && isTop)
            {
                this.TopMost = true;
            }

            // update the tray icon
            if (!ShortTime.Equals(DateTime.Now.ToShortTimeString()))
            {
                ShortTime = DateTime.Now.ToShortTimeString();
                //DrawIcon();
            }
        }
コード例 #21
0
        private void RebuildCerts()
        {
            var cert = new Dictionary <string, byte[]>();

            foreach (var file in Directory.GetFiles(m_path, "*.cer"))
            {
                using (X509Certificate2 certificate = new X509Certificate2(file))
                {
                    cert.Add(certificate.Thumbprint, certificate.RawData);
                }
            }

            m_list            = cert;
            m_lastCertRefresh = ShortTime.Now;
        }
コード例 #22
0
        /// <summary>
        /// Updates the limits associated with this rate limiter. Note, after this update, the tokens will be completely resupplied.
        /// </summary>
        /// <param name="tokensPerSecond">The number of tokens per second that can be generated. Must be greater than zero and less than 1 billion</param>
        /// <param name="maxTokensQueue">The maximum number of tokens in the queue. Must be at least 1</param>
        public void UpdateLimits(double tokensPerSecond, int maxTokensQueue)
        {
            if (double.IsNaN(tokensPerSecond))
                throw new ArgumentException("Cannot be NaN", nameof(tokensPerSecond));
            tokensPerSecond = Math.Min(tokensPerSecond, 1000000000); //1 Billion tokens per second.
            tokensPerSecond = Math.Max(tokensPerSecond, 1.0 / 24.0 / 3600.0); //1 token per day.

            if (maxTokensQueue < 1)
                throw new ArgumentOutOfRangeException(nameof(maxTokensQueue));

            m_maxTokens = maxTokensQueue;
            m_tokens = maxTokensQueue;
            m_tokenPerSecond = tokensPerSecond;
            m_updateTime = ShortTime.Now;
        }
コード例 #23
0
ファイル: Frame.cs プロジェクト: xj0229/gsf
        private IMeasurement m_lastSortedMeasurement;                                        // Last measurement sorted into this frame

        #endregion

        #region [ Constructors ]

        /// <summary>
        /// Constructs a new <see cref="Frame"/> given the specified parameters.
        /// </summary>
        /// <param name="timestamp">Timestamp, in ticks, for this <see cref="Frame"/>.</param>
        /// <param name="expectedMeasurements">Expected number of measurements for the <see cref="Frame"/>.</param>
        public Frame(Ticks timestamp, int expectedMeasurements = -1)
        {
            m_timestamp = timestamp;
            m_lifespan  = ShortTime.Now;

            if (expectedMeasurements > 0)
            {
                m_measurements = new ConcurrentDictionary <MeasurementKey, IMeasurement>(s_defaultConcurrencyLevel, expectedMeasurements * 2);
            }
            else
            {
                m_measurements = new ConcurrentDictionary <MeasurementKey, IMeasurement>();
            }

            m_sortedMeasurements = -1;
        }
コード例 #24
0
ファイル: ThreadPoolMonitor.cs プロジェクト: xj0229/gsf
        static ThreadPoolMonitor()
        {
            if (OptimizationOptions.EnableThreadPoolMonitoring)
            {
                s_monitors = new List <Monitor>();
                s_monitors.Add(new Monitor(0));
                s_monitors.Add(new Monitor(10));
                s_monitors.Add(new Monitor(100));
                s_monitors.Add(new Monitor(1000));

                s_lastResetTime = ShortTime.Now;

                Log.Publish(MessageLevel.Info, "Starting ThreadPool Monitoring.");

                LoadingAdjustedTimestamp.OnHighLoad += LoadingAdjustedTimestamp_OnHighLoad;
            }
        }
コード例 #25
0
        private static void MonitorHighPriority()
        {
            //This one will primarily detect when the process is paused.
            //This occurs when garbage collection occurs.

            ShortTime lastTime = ShortTime.Now;

            while (true)
            {
                try
                {
                    Thread.Sleep(10);
                    ShortTime currentTime = ShortTime.Now;

                    long   sleepDelta        = (long)lastTime.ElapsedTicks(currentTime);
                    long   additionalDelay   = sleepDelta - 10 * TimeSpan.TicksPerMillisecond;
                    double additionalDelayMS = additionalDelay / (double)TimeSpan.TicksPerMillisecond;

                    if (additionalDelayMS > 1000)
                    {
                        LogLarge.Publish(additionalDelayMS.ToString() + " ms (High Priority)");
                    }
                    else if (additionalDelayMS > 300)
                    {
                        LogMedium.Publish(additionalDelayMS.ToString() + " ms (High Priority)");
                    }
                    else if (additionalDelayMS > 100)
                    {
                        LogSmall.Publish(additionalDelayMS.ToString() + " ms (High Priority)");
                    }

                    Interlocked.Increment(ref s_highProcessCount);

                    AdjustRealtime();

                    lastTime = currentTime;
                }
                catch (Exception ex)
                {
                    Log.Publish(MessageLevel.Warning, MessageFlags.BugReport, "Unexpected Exception Caught", null, null, ex);
                    Thread.Sleep(1000);
                }
            }
        }
コード例 #26
0
        private bool CheckOnTime(int checkSpanSeconds, DateTime now)
        {
            if (this.IsExpired(now))
            {
                return(false);
            }
            ShortTime target = new ShortTime(now);

            if (!this.ShortTimeScope.Contains(target))
            {
                return(false);
            }
            DateTime requiredTime = new DateTime();

            switch (this.richTimerType)
            {
            case global::CJBasic.Threading.Timers.RichTimer.RichTimerType.PerHour:
                requiredTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, this.minute, this.second);
                break;

            case global::CJBasic.Threading.Timers.RichTimer.RichTimerType.PerDay:
                requiredTime = new DateTime(now.Year, now.Month, now.Day, this.hour, this.minute, this.second);
                break;

            case global::CJBasic.Threading.Timers.RichTimer.RichTimerType.PerWeek:
                requiredTime = new DateTime(now.Year, now.Month, now.Day, this.hour, this.minute, this.second);
                break;

            case global::CJBasic.Threading.Timers.RichTimer.RichTimerType.PerMonth:
                requiredTime = new DateTime(now.Year, now.Month, this.Day, this.hour, this.minute, this.second);
                break;

            case global::CJBasic.Threading.Timers.RichTimer.RichTimerType.EverySpan:
            {
                int cycleSpanInSecs = ((this.hour * 0xe10) + (this.minute * 60)) + this.second;
                return((cycleSpanInSecs > 0) && TimeHelper.IsOnTime(this.shortTimeScope.ShortTimeStart.GetDateTime(), now, cycleSpanInSecs, checkSpanSeconds));
            }

            case global::CJBasic.Threading.Timers.RichTimer.RichTimerType.JustOnce:
                requiredTime = this.targetTimeForJustOnce;
                break;
            }
            return(TimeHelper.IsOnTime(requiredTime, now, checkSpanSeconds));
        }
コード例 #27
0
ファイル: ThreadPoolMonitor.cs プロジェクト: xj0229/gsf
            private void task_Running(object sender, EventArgs <ScheduledTaskRunningReason> e)
            {
                ShortTime currentTime = ShortTime.Now;
                ShortTime queueTime;

                lock (this)
                {
                    if (!m_time.HasValue)
                    {
                        return; //Should never happen, but just in case;
                    }
                    queueTime = m_time.Value;
                    m_time    = null;
                }

                double delay = (currentTime - queueTime).TotalMilliseconds;

                if (delay > m_delay + 1000)
                {
                    m_logLarge.Publish(delay.ToString() + " ms");
                }
                else if (delay > m_delay + 500)
                {
                    m_logMedium.Publish(delay.ToString() + " ms");
                }
                else if (delay > m_delay + 100)
                {
                    m_logSmall.Publish(delay.ToString() + " ms");
                }
                else
                {
                    return;
                }

                //If I published a message, a long delay could have occurred and messed
                //up my timer, therefore reset the current time.
                lock (this)
                {
                    if (m_time.HasValue)
                    {
                        m_time = ShortTime.Now;
                    }
                }
            }
コード例 #28
0
        /// <summary>
        /// Creates a <see cref="RouteMappingHighLatencyLowCpu"/>
        /// </summary>
        public RouteMappingHighLatencyLowCpu()
        {
            m_lastStatusUpdate       = ShortTime.Now;
            m_maxPendingMeasurements = 1000;
            m_routeLatency           = OptimizationOptions.RoutingLatency;
            m_batchSize    = OptimizationOptions.RoutingBatchSize;
            m_inboundQueue = new ConcurrentQueue <List <IMeasurement> >();

            m_task                     = new ScheduledTask(ThreadingMode.DedicatedBackground, ThreadPriority.AboveNormal);
            m_task.Running            += m_task_Running;
            m_task.UnhandledException += m_task_UnhandledException;
            m_task.Disposing          += m_task_Disposing;
            m_task.Start(m_routeLatency);

            m_onStatusMessage    = x => { };
            m_onProcessException = x => { };
            m_globalCache        = new GlobalCache(new Dictionary <IAdapter, Consumer>(), 0);
            RouteCount           = m_globalCache.GlobalSignalLookup.Count(x => x != null);
        }
コード例 #29
0
        /// <summary>
        /// Updates the limits associated with this rate limiter. Note, after this update, the tokens will be completely resupplied.
        /// </summary>
        /// <param name="tokensPerSecond">The number of tokens per second that can be generated. Must be greater than zero and less than 1 billion</param>
        /// <param name="maxTokensQueue">The maximum number of tokens in the queue. Must be at least 1</param>
        public void UpdateLimits(double tokensPerSecond, int maxTokensQueue)
        {
            if (double.IsNaN(tokensPerSecond))
            {
                throw new ArgumentException("Cannot be NaN", nameof(tokensPerSecond));
            }
            tokensPerSecond = Math.Min(tokensPerSecond, 1000000000);          //1 Billion tokens per second.
            tokensPerSecond = Math.Max(tokensPerSecond, 1.0 / 24.0 / 3600.0); //1 token per day.

            if (maxTokensQueue < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxTokensQueue));
            }

            m_maxTokens      = maxTokensQueue;
            m_tokens         = maxTokensQueue;
            m_tokenPerSecond = tokensPerSecond;
            m_updateTime     = ShortTime.Now;
        }
コード例 #30
0
        /// <summary>
        /// Attempts to take a token from the rate limiter.
        /// </summary>
        /// <returns>true if token was successfully taken, False if all tokens were consumed.</returns>
        public bool TryTakeToken()
        {
            var currentTime = ShortTime.Now;
            var tokensGenerated = m_updateTime.ElapsedSeconds(currentTime) * m_tokenPerSecond;

            //To limit rounding errors at high call rates, 
            //do not add a token until it acumiliates to a relatively large value.
            if (tokensGenerated > 0.5)
            {
                m_tokens = Math.Min(m_tokens + tokensGenerated, m_maxTokens);
                m_updateTime = currentTime;
            }

            if (m_tokens < 0.99)
                return false;

            m_tokens--;
            return true;
        }
コード例 #31
0
        private void RebuildCerts()
        {
            var cert = new Dictionary <string, Tuple <string, byte[]> >();

            foreach (var item in m_config.Accounts)
            {
                if (Directory.Exists(item.CertificateDirectory))
                {
                    foreach (var file in Directory.GetFiles(item.CertificateDirectory, "*.cer"))
                    {
                        X509Certificate2 certificate = new X509Certificate2(file);
                        cert.Add(certificate.Thumbprint, new Tuple <string, byte[]>(item.Name, certificate.RawData));
                        certificate.Dispose();
                    }
                }
            }

            m_certificateAccounts = cert;
            m_lastCertRefresh     = ShortTime.Now;
        }
コード例 #32
0
        /// <summary>
        /// Creates a <see cref="LogEventPublisherInternal"/>.
        /// </summary>
        /// <param name="attributes"></param>
        /// <param name="owner">the owner of the log messages.</param>
        /// <param name="publisher">the publisher that is used to raise messages</param>
        /// <param name="logger">the callback for all new messages that are generated.</param>
        /// <param name="stackTraceDepth"></param>
        /// <param name="messagesPerSecond"></param>
        /// <param name="burstLimit"></param>
        internal LogEventPublisherInternal(LogMessageAttributes attributes, LogEventPublisherDetails owner, LogPublisherInternal publisher, LoggerInternal logger, int stackTraceDepth, double messagesPerSecond, int burstLimit)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));
            if (publisher == null)
                throw new ArgumentNullException(nameof(publisher));
            if (logger == null)
                throw new ArgumentNullException(nameof(logger));

            m_attributes = attributes;
            var supression = new LogSuppressionEngine(messagesPerSecond, burstLimit);

            m_owner = owner;
            m_logger = logger;
            m_stackTraceDepth = 0;
            m_supressionEngine = supression;
            m_publisher = publisher;
            m_stackTraceDepth = stackTraceDepth;
            m_suppressionMessageNextPublishTime = ShortTime.Now;
        }
コード例 #33
0
        /// <summary>
        /// Attempts to take a token from the rate limiter.
        /// </summary>
        /// <returns>true if token was successfully taken, False if all tokens were consumed.</returns>
        public bool TryTakeToken()
        {
            var currentTime     = ShortTime.Now;
            var tokensGenerated = m_updateTime.ElapsedSeconds(currentTime) * m_tokenPerSecond;

            //To limit rounding errors at high call rates,
            //do not add a token until it acumiliates to a relatively large value.
            if (tokensGenerated > 0.5)
            {
                m_tokens     = Math.Min(m_tokens + tokensGenerated, m_maxTokens);
                m_updateTime = currentTime;
            }

            if (m_tokens < 0.99)
            {
                return(false);
            }

            m_tokens--;
            return(true);
        }
コード例 #34
0
        public static string DateExtended(int value)
        {
            var dateTime = Utils.UnixTimestampToDateTime(value);

            //Today
            if (dateTime.Date == System.DateTime.Now.Date)
            {
                //TimeLabel.Text = dateTime.ToString(string.Format("{0}", shortTimePattern), cultureInfo);
                return(ShortTime.Format(dateTime));
            }

            //Week
            if (dateTime.Date.AddDays(6) >= System.DateTime.Now.Date)
            {
                return(DayOfWeekAbbreviated.Format(dateTime));
            }

            //Long long time ago
            //TimeLabel.Text = dateTime.ToString(string.Format("d.MM.yyyy", shortTimePattern), cultureInfo);
            return(ShortDate.Format(dateTime));
        }
コード例 #35
0
ファイル: MainWindow.xaml.cs プロジェクト: zhenghua75/DXInfo
        /// <summary>
        /// Media opened event handler.
        /// Set Media size when it opened.
        /// </summary>
        /// <param name="milliseconds"></param>
        void mediaWindow_OnMediaOpened(double milliseconds)
        {
            this.positionSlider.Maximum = milliseconds;

            if (this.mediaWindow.HasVideo)
            {
                this.VideoSize = String.Format(" / Video size : {0} x {1}", this.mediaWindow.VideoWidth, this.mediaWindow.VideoHeight);
            }
            else
            {
                this.VideoSize = null;
            }

            string time = ShortTime.TimeToString(new TimeSpan(0, 0, (int)(this.positionSlider.Maximum / 1000)));

            if (this.listWindow != null && this.listWindow.PlayedMediaItem != null)
            {
                ItemContent content = ((ItemContent)this.listWindow.PlayedMediaItem.Content);
                content.Time = time;
                MediaInfo mi = this.mediaWindow.GetPlayedMediaInfo();
                content.MediaType  = mi.MediaType;
                content.Resolution = mi.Resolution;
            }
        }
コード例 #36
0
 public string Date(int value)
 {
     return(ShortTime.Format(DateTime(value)));
 }
コード例 #37
0
        /// <summary>
        /// Creates a <see cref="RouteMappingHighLatencyLowCpu"/>
        /// </summary>
        public RouteMappingHighLatencyLowCpu()
        {
            m_lastStatusUpdate = ShortTime.Now;
            m_maxPendingMeasurements = 1000;
            m_routeLatency = OptimizationOptions.RoutingLatency;
            m_batchSize = OptimizationOptions.RoutingBatchSize;
            m_inboundQueue = new ConcurrentQueue<List<IMeasurement>>();

            m_task = new ScheduledTask(ThreadingMode.DedicatedBackground, ThreadPriority.AboveNormal);
            m_task.Running += m_task_Running;
            m_task.UnhandledException += m_task_UnhandledException;
            m_task.Disposing += m_task_Disposing;
            m_task.Start(m_routeLatency);

            m_onStatusMessage = x => { };
            m_onProcessException = x => { };
            m_globalCache = new GlobalCache(new Dictionary<IAdapter, Consumer>(), 0);
            RouteCount = m_globalCache.GlobalSignalLookup.Count(x => x != null);
        }
コード例 #38
0
        void m_task_Running(object sender, EventArgs<ScheduledTaskRunningReason> e)
        {
            if (e.Argument == ScheduledTaskRunningReason.Disposing)
                return;

            m_task.Start(m_routeLatency);

            m_routeOperations++;

            if (m_lastStatusUpdate.ElapsedSeconds() > 15)
            {
                m_lastStatusUpdate = ShortTime.Now;
                Log.Publish(MessageLevel.Info, MessageFlags.None, "Routing Update",
                string.Format("Route Operations: {0}, Input Frames: {1}, Input Measurements: {2}, Output Measurements: {3}",
                            m_routeOperations, m_measurementsRoutedInputFrames,
                            m_measurementsRoutedInputMeasurements,
                            m_measurementsRoutedOutput));
            }

            var map = m_globalCache;

            try
            {
                int measurementsRouted = 0;

                List<IMeasurement> measurements;
                while (m_inboundQueue.TryDequeue(out measurements))
                {
                    measurementsRouted += measurements.Count;
                    Interlocked.Add(ref m_pendingMeasurements, -measurements.Count);

                    //For loops are faster than ForEach for List<T>
                    //Process Optimized Consumers
                    for (int x = 0; x < map.RoutingPassthroughAdapters.Count; x++)
                    {
                        map.RoutingPassthroughAdapters[x].ProcessMeasurementList(measurements);
                    }

                    //Process Broadcast Consumers
                    for (int x = 0; x < map.BroadcastConsumers.Count; x++)
                    {
                        m_measurementsRoutedOutput += measurements.Count;
                        map.BroadcastConsumers[x].MeasurementsToRoute.AddRange(measurements);
                    }

                    m_measurementsRoutedInputFrames++;
                    m_measurementsRoutedInputMeasurements += measurements.Count;
                    for (int x = 0; x < measurements.Count; x++)
                    {
                        var measurement = measurements[x];
                        List<Consumer> consumers = map.GlobalSignalLookup[measurement.Key.RuntimeID];
                        if (consumers != null)
                        {
                            for (int i = 0; i < consumers.Count; i++)
                            {
                                m_measurementsRoutedOutput++;
                                consumers[i].MeasurementsToRoute.Add(measurement);
                            }
                        }
                    }

                    //If any adapter has too many measurements on their batch
                    //Route all adapter's measurements
                    if (measurementsRouted > m_batchSize)
                    {
                        measurementsRouted = 0;
                        foreach (var consumer in map.NormalDestinationAdapters)
                        {
                            measurementsRouted = Math.Max(measurementsRouted, consumer.MeasurementsToRoute.Count);
                            if (consumer.MeasurementsToRoute.Count > m_batchSize)
                            {
                                foreach (var c2 in map.NormalDestinationAdapters)
                                {
                                    c2.RoutingComplete();
                                }
                                measurementsRouted = 0;
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                foreach (var consumer in map.NormalDestinationAdapters)
                {
                    consumer.RoutingComplete();
                }
            }
        }
コード例 #39
0
        /// <summary>
        /// Raises a log message with the provided data.
        /// </summary>
        /// <param name="overriddenAttributes">attributes to use with this message</param>
        /// <param name="message"></param>
        /// <param name="details">A long text field with the details of the message.</param>
        /// <param name="exception">An exception object if one is provided.</param>
        /// <param name="initialStackMessage"></param>
        /// <param name="initialStackTrace"></param>
        public void Publish(LogMessageAttributes? overriddenAttributes, string message, string details, Exception exception, LogStackMessages initialStackMessage, LogStackTrace initialStackTrace)
        {
            if (Logger.ShouldSuppressLogMessages)
                return;

            LogMessageAttributes attributes = overriddenAttributes ?? m_attributes;

            if (!m_publisher.HasSubscribers(attributes))
                return;

            if (message == null)
                message = string.Empty;
            if (details == null)
                details = string.Empty;

            var suppressionFlags = m_supressionEngine.IncrementPublishCount();
            if (suppressionFlags != MessageSuppression.None)
            {
                m_messagesSuppressed++;

                if (ShouldRaiseMessageSupressionNotifications && m_suppressionMessageNextPublishTime <= ShortTime.Now)
                {
                    m_suppressionMessageNextPublishTime = ShortTime.Now.AddSeconds(10);
                    MessageSuppressionIndication.Publish($"Message Suppression Is Occurring To: '{ m_owner.TypeData.TypeName }' {m_messagesSuppressed.ToString()} total messages have been suppressed.", m_owner.ToString());
                }

                attributes += suppressionFlags;
                if (!m_publisher.HasSubscribers(attributes))
                    return;
            }

            LogStackMessages currentStackMessages = Logger.GetStackMessages();
            LogStackTrace currentStackTrace = LogStackTrace.Empty;
            if (m_stackTraceDepth > 0)
            {
                currentStackTrace = new LogStackTrace(true, 2, m_stackTraceDepth);
            }
            else if (exception != null || attributes.Level >= MessageLevel.Error)
            {
                currentStackTrace = new LogStackTrace(true, 2, 10);
            }

            var logMessage = new LogMessage(m_owner, initialStackMessage, initialStackTrace, currentStackMessages, currentStackTrace, attributes, message, details, exception);
            m_logger.OnNewMessage(logMessage, m_publisher);
        }
コード例 #40
0
        private bool CheckOnTime(int checkSpanSeconds ,DateTime now)
        {  
            if (this.IsExpired(now))
            {
                return false;
            }

            ShortTime target = new ShortTime(now);
            if (! this.ShortTimeScope.Contains(target))
            {
                return false;
            }

            DateTime onTime = new DateTime();

            switch (this.richTimerType)
            {
                case RichTimerType.PerDay:
                    {
                        onTime = new DateTime(now.Year, now.Month, now.Day, this.hour, this.minute, this.second);
                        break;
                    }
                case RichTimerType.PerHour:
                    {
                        onTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, this.minute, this.second);
                        break;
                    }
                case RichTimerType.PerMonth:
                    {
                        onTime = new DateTime(now.Year, now.Month, this.Day, this.hour, this.minute, this.second);
                        break;
                    }
                case RichTimerType.PerWeek:
                    {
                        onTime = new DateTime(now.Year, now.Month, now.Day, this.hour, this.minute, this.second);
                        break;
                    }
                case RichTimerType.JustOnce:
                    {
                        onTime = this.targetTimeForJustOnce;
                        break;
                    }
                case RichTimerType.EverySpan:
                    {
                        int cycleSpanInSecs = (this.hour * 3600 + this.minute * 60 + this.second);
                        if (cycleSpanInSecs <= 0)
                        {
                            return false;
                        }

                        return TimeHelper.IsOnTime(this.shortTimeScope.ShortTimeStart.GetDateTime(), now, cycleSpanInSecs, checkSpanSeconds);   
                    }
                
                default:
                    {
                        break;
                    }
            }

            return TimeHelper.IsOnTime(onTime, now, checkSpanSeconds);
        }
コード例 #41
0
 private static void LoadingAdjustedTimestamp_OnHighLoad()
 {
     if (s_lastResetTime.ElapsedSeconds() > 10)
     {
         s_lastResetTime = ShortTime.Now;
         MonitorThreads();
     }
 }
コード例 #42
0
        public bool IsOnTime(int checkSpanSeconds, DateTime now)
        {
            #region 防止在临界点时,执行两次
            TimeSpan span = now - this.lastRightTime;
            if (span.TotalMilliseconds < checkSpanSeconds * 1000 * 2)
            {
                return false;
            } 
            #endregion
            
            bool isOnTime = false;

            #region Switch
            switch (this.timingTaskType)
            {
                case TimingTaskType.PerHour:
                    {
                        ShortTime temp = new ShortTime(now.Hour, this.excuteTime.Minute, this.excuteTime.Second);
                        isOnTime = temp.IsOnTime(now, checkSpanSeconds);

                        if (!isOnTime)
                        {
                            ShortTime temp2 = new ShortTime(now.AddHours(1).Hour, this.excuteTime.Minute, this.excuteTime.Second);
                            isOnTime = temp2.IsOnTime(now, checkSpanSeconds);
                        }

                        if (!isOnTime)
                        {
                            ShortTime temp3 = new ShortTime(now.AddHours(-1).Hour, this.excuteTime.Minute, this.excuteTime.Second);
                            isOnTime = temp3.IsOnTime(now, checkSpanSeconds);
                        }

                        break;
                    }
                case TimingTaskType.PerDay:
                    {
                        isOnTime = this.excuteTime.IsOnTime(now, checkSpanSeconds);
                        break;
                    }
                case TimingTaskType.PerWeek:
                    {
                        if (now.DayOfWeek != this.dayOfWeek)
                        {
                            isOnTime = false;
                        }
                        else
                        {
                            isOnTime = this.excuteTime.IsOnTime(now, checkSpanSeconds);
                        }
                        break;
                    }
                case TimingTaskType.PerMonth:
                    {
                        if (now.Day != this.day)
                        {
                            isOnTime = false;
                        }
                        else
                        {
                            isOnTime = this.excuteTime.IsOnTime(now, checkSpanSeconds);
                        }
                        break;
                    }
                default:
                    {
                        break;
                    }
            } 
            #endregion

            if (isOnTime)
            {
                this.lastRightTime = now;
            }

            return isOnTime;
        } 
コード例 #43
0
 /// <summary>
 /// Constructs a new <see cref="Measurement"/> using default settings.
 /// </summary>
 public Measurement()
 {
     m_metadata = MeasurementMetadata.Undefined;
     m_lifespan = ShortTime.Now;
 }
コード例 #44
0
        private static void AdjustRealtime()
        {
            //This method is supposed to be called every 10 milliseconds on a high priority thread.
            //However don't update the time unless 100ms has elapsed.

            //Since DateTime can be programmatically changed, I'm using CPU Registers.
            long physicalTimeSinceLastSet = (long)s_currentTimeSetTime.ElapsedTicks();
            if (physicalTimeSinceLastSet < 100 * TimeSpan.TicksPerMillisecond)
                return;

            long clockSinceLastSet = DateTime.UtcNow.Ticks - s_currentTime;

            if (Math.Abs(physicalTimeSinceLastSet - clockSinceLastSet) > TimeSpan.TicksPerSecond)
            {
                Log.Publish(MessageLevel.Warning, MessageFlags.SystemHealth,
                    "System time has been adjusted by more than 1 second. Resetting Loading Figures.",
                    $"Expected Clock Change: {physicalTimeSinceLastSet / TimeSpan.TicksPerMillisecond} ms, Clock change: {clockSinceLastSet / TimeSpan.TicksPerMillisecond}");

                Reset();
                return;
            }
            if (clockSinceLastSet < 0)
            {
                Log.Publish(MessageLevel.Info, MessageFlags.SystemHealth, "System Clock did not advance.",
                    $"Expected Clock Change: {physicalTimeSinceLastSet / TimeSpan.TicksPerMillisecond} ms, Clock change: {clockSinceLastSet / TimeSpan.TicksPerMillisecond}");
            }

            int highDelay = Interlocked.Exchange(ref s_highProcessCount, 0);
            int normalDelay = Interlocked.Exchange(ref s_normalProcessCount, 0);
            int lowDelay = Interlocked.Exchange(ref s_lowProcessCount, 0);

            if (highDelay >= 5 && lowDelay <= 1)
            {
                try
                {
                    OnHighLoad?.Invoke();
                }
                catch (Exception)
                {

                }
            }

            long maxAdjustment = 0;
            if (lowDelay >= 7)
            {
                maxAdjustment = 500 * TimeSpan.TicksPerMillisecond;
            }
            else if (lowDelay >= 5)
            {
                maxAdjustment = 400 * TimeSpan.TicksPerMillisecond;
            }
            else if (normalDelay >= 7)
            {
                maxAdjustment = 300 * TimeSpan.TicksPerMillisecond;
            }
            else if (normalDelay >= 5)
            {
                maxAdjustment = 200 * TimeSpan.TicksPerMillisecond;
            }
            else if (highDelay >= 4)
            {
                maxAdjustment = 100 * TimeSpan.TicksPerMillisecond;
            }
            else
            {
                maxAdjustment = 50 * TimeSpan.TicksPerMillisecond;
            }

            if (maxAdjustment < clockSinceLastSet)
            {
                LogLoadingClock.Publish($"Behind by {clockSinceLastSet / TimeSpan.TicksPerMillisecond}ms adjusting by {maxAdjustment / TimeSpan.TicksPerMillisecond}ms");
            }

            long adjustment = Math.Min(clockSinceLastSet, maxAdjustment);

            if (adjustment >= 0)
            {
                Interlocked.Exchange(ref s_currentTime, s_currentTime + adjustment);
            }
            s_currentTimeSetTime = ShortTime.Now;
        }
コード例 #45
0
 private static void Reset()
 {
     Interlocked.Exchange(ref s_currentTime, DateTime.UtcNow.Ticks);
     s_currentTimeSetTime = ShortTime.Now;
     Interlocked.Exchange(ref s_highProcessCount, 0);
     Interlocked.Exchange(ref s_normalProcessCount, 0);
     Interlocked.Exchange(ref s_lowProcessCount, 0);
 }
コード例 #46
0
        static ThreadPoolMonitor()
        {
            if (OptimizationOptions.EnableThreadPoolMonitoring)
            {
                s_monitors = new List<Monitor>();
                s_monitors.Add(new Monitor(0));
                s_monitors.Add(new Monitor(10));
                s_monitors.Add(new Monitor(100));
                s_monitors.Add(new Monitor(1000));

                s_lastResetTime = ShortTime.Now;

                Log.Publish(MessageLevel.Info, "Starting ThreadPool Monitoring.");

                LoadingAdjustedTimestamp.OnHighLoad += LoadingAdjustedTimestamp_OnHighLoad;
            }
        }