Example #1
0
        private async void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            TimedInterfaceServiceTimer serviceTimer = sender as TimedInterfaceServiceTimer;

            serviceTimer.Stop();

            try
            {
                await this.HandleRunAfterAttributeForTimedInterface(serviceTimer.TimedInterface);

                await this.ExecuteInterface(serviceTimer.TimedInterface);

                if (serviceTimer.Interval != serviceTimer.TimedInterface.Interval.TotalMilliseconds)
                {
                    serviceTimer.Interval = serviceTimer.TimedInterface.Interval.TotalMilliseconds;
                }
            }
            catch (Exception ex)
            {
                await ex.LogException(serviceTimer.TimedInterface.GetType().Name);

                serviceTimer.Interval = TimeSpan.FromHours(6).TotalMilliseconds;
            }
            finally
            {
                serviceTimer.Start();
            }
        }
Example #2
0
        private async void StartTimer(TimedInterfaceServiceTimer timer)
        {
#if DEBUG
            await this.HandleRunAfterAttributeForTimedInterface(timer.TimedInterface);

            // Execute the interface initially, otherwise will have to wait for the first timer to elapse before anything happens.
            await this.ExecuteInterface(timer.TimedInterface);
#endif

            timer.Start();
        }