コード例 #1
0
ファイル: Scheduler.cs プロジェクト: shrekjxf/Rpi
        public void Schedule(ScheduledAsyncAction subscriber, ScheduleOptions options)
        {
            // Check for existing subscription
            var sub = GetSubscription(subscriber, false);

            if (sub != null)
            {
                throw new InvalidOperationException("Already subscribed");
            }

            // Make sure lookup exists
            if (m_AsyncSubscriptions == null)
            {
                m_AsyncSubscriptions = new Lookup <ScheduledAsyncAction>();
            }

            // Threadsafe
            lock (m_AsyncSubscriptions)
            {
                // Add lookup
                m_AsyncSubscriptions[subscriber] = new Subscription()
                {
                    Options = options
                };
            }

            // Ensure interval
            EnsureMinReportInterval(options.UpdateInterval);

            // Start?
            QueryStart();
        }
コード例 #2
0
ファイル: ScheduledUpdater.cs プロジェクト: shrekjxf/Rpi
        private void UpdateScheduleOptions(ScheduleOptions options)
        {
            // Validate
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Ensure changing
            if (options == m_ScheduleOptions)
            {
                return;
            }

            // Update variable first
            m_ScheduleOptions = options;

            // If current scheduled, update the schedule
            if (m_Scheduled)
            {
                if (m_AsyncUpdateAction != null)
                {
                    m_Scheduler.UpdateSchedule(m_AsyncUpdateAction, options);
                }
                else
                {
                    m_Scheduler.UpdateSchedule(m_UpdateAction, options);
                }
            }
        }
コード例 #3
0
ファイル: ScheduledUpdater.cs プロジェクト: shrekjxf/Rpi
        private void SetUpdateInterval(uint newInterval)
        {
            // Create new options
            var options = ScheduleOptions.WithNewUpdateInterval(newInterval);

            // Update
            UpdateScheduleOptions(options);
        }
コード例 #4
0
ファイル: ScheduledUpdater.cs プロジェクト: shrekjxf/Rpi
        public ScheduledUpdater(ScheduleOptions scheduleOptions, Scheduler scheduler)
        {
            // Store
            m_Scheduler              = scheduler ?? throw new ArgumentNullException("scheduler");
            m_ScheduleOptions        = scheduleOptions ?? throw new ArgumentNullException("scheduleOptions");
            m_DefaultScheduleOptions = scheduleOptions;

            // Defaults
            StartWithEvents = true;
            StopWithEvents  = true;
        }
コード例 #5
0
ファイル: Scheduler.cs プロジェクト: shrekjxf/Rpi
 public void UpdateSchedule(ScheduledAsyncAction subscriber, ScheduleOptions options)
 {
     GetSubscription(subscriber).Options = options ?? throw new ArgumentNullException("options");
     if (m_ReportInterval < options.UpdateInterval)
     {
         EnsureMinReportInterval(options.UpdateInterval);
     }
     else
     {
         RecalcReportInterval();
     }
 }
コード例 #6
0
ファイル: ScheduledUpdater.cs プロジェクト: shrekjxf/Rpi
 public ScheduledUpdater(ScheduleOptions scheduleOptions) : this(scheduleOptions, Scheduler.Default)
 {
 }