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(); }
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); } } }
private void SetUpdateInterval(uint newInterval) { // Create new options var options = ScheduleOptions.WithNewUpdateInterval(newInterval); // Update UpdateScheduleOptions(options); }
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; }
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(); } }
public ScheduledUpdater(ScheduleOptions scheduleOptions) : this(scheduleOptions, Scheduler.Default) { }