/// <summary> /// Initializes a new instance of the <see cref="PropertyReferenceObserverOnValueChangedWithDefer{TResult}" /> class. /// </summary> /// <param name="propertyExpression">The property expression.</param> /// <param name="observerFlag">The observer flag.</param> /// <exception cref="ArgumentNullException">propertyExpression is null.</exception> internal PropertyReferenceObserverOnValueChangedWithDefer( [NotNull] Expression <Func <TResult> > propertyExpression, PropertyObserverFlag observerFlag) : base(propertyExpression, observerFlag) { propertyExpression = propertyExpression ?? throw new ArgumentNullException(nameof(propertyExpression)); var getter = ExpressionGetter.CreateReferenceGetter <TResult>(propertyExpression.Parameters, this.Tree); this.deferrer = new UpdateableMultibleDeferrer(() => this.Value = getter()); this.action = () => this.deferrer.Update(); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyReferenceObserverOnValueChangedWithDefer{TParameter1, TResult}" /> class. /// </summary> /// <param name="parameter1">The parameter1.</param> /// <param name="propertyExpression">The property expression.</param> /// <param name="taskScheduler">The task scheduler.</param> /// <param name="observerFlag">The observer flag.</param> /// <exception cref="ArgumentNullException">propertyExpression is null.</exception> internal PropertyReferenceObserverOnValueChangedWithDefer( [NotNull] TParameter1 parameter1, [NotNull] Expression <Func <TParameter1, TResult> > propertyExpression, TaskScheduler taskScheduler, PropertyObserverFlag observerFlag) : base(parameter1, propertyExpression, observerFlag) { propertyExpression = propertyExpression ?? throw new ArgumentNullException(nameof(propertyExpression)); var getter = ExpressionGetter.CreateReferenceGetter <TResult>(propertyExpression.Parameters, this.Tree); this.deferrer = new UpdateableMultibleDeferrer( () => new TaskFactory(taskScheduler).StartNew(() => this.Value = getter()).Wait()); this.action = () => this.deferrer.Update(); }