public ComputedCollection(Func <IEnumerable <T> > getMethod) { _getMethod = getMethod; _depCollection = new Computed(OnUpdateCollection); _depCollection.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow); _depCollection.Touch(); }
private void Invalidated() { // When the "can execute" flag is invalidated, we need to queue // up a call to update it. This will cause the UI thread to // call TriggerUpdate (below) when everything settles down. UpdateScheduler.ScheduleUpdate(UpdateNow); }
public void Start() { if (_computed == null) { throw new InvalidOperationException("Cannot restart ComputedJob"); } _running = true; UpdateScheduler.ScheduleUpdate(UpdateNow); }
public static UpdateScheduler Begin() { // If someone is already capturing the affected set, // let them keep that responsibility. if (_currentSet.Value != null) return null; UpdateScheduler currentSet = new UpdateScheduler(); _currentSet.Value = currentSet; return currentSet; }
public static void ScheduleUpdate(Action update) { UpdateScheduler currentSet = _currentSet.Value; if (currentSet != null) { currentSet._updatables.Add(update); } else if (_runOnUIThread != null) { _runOnUIThread(update); } }
public static void Initialize() { // Ensure that the UpdateScheduler has the ability to run delegates // on the UI thread. if (_mainDispatcher == null) { #if WPF _mainDispatcher = Dispatcher.CurrentDispatcher; #endif UpdateScheduler.Initialize(RunOnUIThread); FloatingTimeZone.Initialize(RunOnUIThread); } }
public static UpdateScheduler Begin() { // If someone is already capturing the affected set, // let them keep that responsibility. if (_currentSet.Value != null) { return(null); } UpdateScheduler currentSet = new UpdateScheduler(); _currentSet.Value = currentSet; return(currentSet); }
public void Execute(object parameter) { var scheduler = UpdateScheduler.Begin(); try { // Execute the command. _execute(); } finally { if (scheduler != null) { foreach (var updatable in scheduler.End()) { updatable(); } } } }
public ComputedAtom(Action firePropertyChanged, Func <T> getMethod) { _firePropertyChanged = firePropertyChanged; _depValue = new Computed(() => _value = getMethod()); _depValue.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow); }
public ViewModelContainer(Action firePropertyChanged, Func <object> constructor) { _computed = new Computed(() => _viewModel = ForView.Wrap(constructor())); _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(firePropertyChanged); }
public ComputedJob(Action action) { _computed = new Computed(action); _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow); }