コード例 #1
0
        void t_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                //LogInfor.GetLogger<TimerLogger>().WriteInfo(_baseKey.Format() + " - Start job", "", "");

                if (UnitContainer != null)
                {
                    //Store the info of timer
                    if (!this.Parameters.AllKeys.Contains(JobDictionary.JOB_INTERNAL_TIMER_PATTERN))
                    {
                        this.Parameters.Add(JobDictionary.JOB_INTERNAL_TIMER_PATTERN, null);
                    }
                    if (!this.Parameters.AllKeys.Contains(JobDictionary.JOB_INTERNAL_TIMER_TIME))
                    {
                        this.Parameters.Add(JobDictionary.JOB_INTERNAL_TIMER_TIME, t.Interval.ToString());
                    }

                    UnitContainer.InvokeALL(this.Parameters);
                }
            }
            catch
            {
            }
            finally
            {
                //Collect garbage manually
                GC.Collect();
                GC.WaitForFullGCComplete();
                //Raise event manually
                t.Enabled = true;
                //LogInfor.GetLogger<TimerLogger>().WriteInfo(_baseKey.Format() + " - Left time[" + (t.Interval / 100).ToString() + "s]", "", "");
            }
        }
コード例 #2
0
        public override void Run()
        {
            var baseKey = new JobMessage()
            {
                Category = "01", Name = this.Name, BaseKey = Guid.NewGuid()
            };

            //the time at which the job will run
            var currentBaseTimePoint = DateTime.Now.Date.Add(startSpan);

            var baseDate = DateTime.Now <= currentBaseTimePoint?currentBaseTimePoint.AddDays(-1) : currentBaseTimePoint;

            while (_running)
            {
                var nextDay = baseDate.AddDays(1);
                //current data is greater than baseDate if the job is running slowly
                while (nextDay < DateTime.Now)
                {
                    baseDate = nextDay;
                    nextDay  = nextDay.AddDays(1);
                }
                var baseTime = nextDay - baseDate;

                if (!TimePending.Pending(baseTime, baseDate, baseKey))
                {
                    if (UnitContainer != null && _running)
                    {
                        //Store the info of timer
                        if (!this.Parameters.AllKeys.Contains(JobDictionary.JOB_INTERNAL_TIMER_PATTERN))
                        {
                            this.Parameters.Add(JobDictionary.JOB_INTERNAL_TIMER_PATTERN, null);
                        }
                        if (!this.Parameters.AllKeys.Contains(JobDictionary.JOB_INTERNAL_TIMER_TIME))
                        {
                            this.Parameters.Add(JobDictionary.JOB_INTERNAL_TIMER_TIME, Parameters["jobTime"]);
                        }

                        UnitContainer.InvokeALL(this.Parameters);
                    }
                    baseDate = nextDay;
                    GC.Collect();
                    GC.WaitForFullGCComplete();
                }
            }
        }
コード例 #3
0
        private void _run()
        {
            if (UnitContainer != null && _running)
            {
                //Store the info of timer
                if (!this.Parameters.AllKeys.Contains(JobDictionary.JOB_INTERNAL_TIMER_PATTERN))
                {
                    this.Parameters.Add(JobDictionary.JOB_INTERNAL_TIMER_PATTERN, JobTimeFormatter.Pattern);
                }
                if (!this.Parameters.AllKeys.Contains(JobDictionary.JOB_INTERNAL_TIMER_TIME))
                {
                    this.Parameters.Add(JobDictionary.JOB_INTERNAL_TIMER_TIME, JobTimeFormatter.RawTime);
                }

                UnitContainer.InvokeALL(this.Parameters);
            }
            GC.Collect();
            GC.WaitForFullGCComplete();
        }