Exemplo n.º 1
0
        private void timerCallback(object state)
        {
            lock (timer)
            {
                IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type);

                backgroundService.RefreshSettings();

                if (backgroundService.Enabled)
                {
                    //TODO: (erikpo) Instead of eating the exception, log it
                    try
                    {
                        backgroundService.Run();
                    }
                    catch
                    {
                    }
                }

                timer.Change(backgroundService.Interval, new TimeSpan(0, 0, 0, 0, -1));
            }

            //TODO: (erikpo) Once background services have a cancel state and timeout interval, check their state and cancel if appropriate
        }
Exemplo n.º 2
0
        public void Start()
        {
            IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type);

            backgroundService.RefreshSettings();

            //INFO: (erikpo) This check is just to make sure a value was provided for interval and that they can't put in an interval that will take down their server
            if (backgroundService.Interval.TotalSeconds > 10)
            {
#if DEBUG
                if (backgroundService.Enabled)
                {
                    backgroundService.Run();
                }
#endif

                isExecuting = false;

                timer = new Timer(
                    timerCallback,
                    null,
                    backgroundService.Interval,
                    new TimeSpan(0, 0, 0, 0, -1)
                    );
            }
        }
Exemplo n.º 3
0
        public void Start()
        {
            IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type);

            backgroundService.RefreshSettings();

            //INFO: (erikpo) This check is just to make sure a value was provided for interval and that they can't put in an interval that will take down their server
            if (backgroundService.Interval.TotalSeconds > 10)
            {
#if DEBUG
                //if (backgroundService.Enabled)
                //{
                //    backgroundService.Run();
                //}
#endif

                isExecuting = false;

                timer = new Timer(
                    timerCallback,
                    null,
                    backgroundService.Interval,
                    backgroundService.Interval
                    );

                EyouSoft.Toolkit.Utils.WLog(string.Format("开启后台服务:Name={0} GUID={1} Interval={2}", backgroundService.Name, backgroundService.ID, backgroundService.Interval), "/log/service.start.log");
            }
        }
Exemplo n.º 4
0
        private void timerCallback(object state)
        {
            if (!isExecuting)
            {
                IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type);

                backgroundService.RefreshSettings();

                if (backgroundService.Enabled)
                {
                    isExecuting = true;

                    backgroundService.Run();

                    isExecuting = false;
                }
            }

            //TODO: (erikpo) Once background services have a cancel state and timeout interval, check their state and cancel if appropriate
        }