예제 #1
0
 public ComputedCollection(Func <IEnumerable <T> > getMethod)
 {
     _getMethod                  = getMethod;
     _depCollection              = new Computed(OnUpdateCollection);
     _depCollection.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     _depCollection.Touch();
 }
예제 #2
0
 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);
            }
        }
예제 #6
0
        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);
        }
예제 #8
0
            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();
                        }
                    }
                }
            }
예제 #9
0
 public ComputedAtom(Action firePropertyChanged, Func <T> getMethod)
 {
     _firePropertyChanged   = firePropertyChanged;
     _depValue              = new Computed(() => _value = getMethod());
     _depValue.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
 }
예제 #10
0
 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);
 }