Click or drag to resize

WaitUntilTrue Method (FuncBoolean, INotifyPropertyChanged)

Suspend coroutine until the supplied expression is true.

Namespace:  Demo3D.Native
Assembly:  Demo3D.Core (in Demo3D.Core.dll) Version: 15.0.2.11458
Syntax
C#
public static ITask UntilTrue(
	Func<bool> expression,
	params INotifyPropertyChanged[] observables
)

Parameters

expression
Type: SystemFuncBoolean
Expression to suspend until true.
observables
Type: System.ComponentModelINotifyPropertyChanged
Collection of INotifyPropertyChanged objects to re-evaluate the expression for when they change.

Return Value

Type: ITask
A task representing the wait for expression to become true.
Examples
C#
// CustomProperty implements INotifyPropertyChanged which is how the Wait methods
// all work but here is an example of implementing your own class which can be waited on.
public class CustomClass : INotifyPropertyChanged {
    public event PropertyChangedEventHandler PropertyChanged;

    void OnPropertyChanged([CallerMemberName]string propertyName="") {
        if (PropertyChanged != null) {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    private int a;
    public int A {
        get { return a; }
        set { a = value; OnPropertyChanged(); }
    }
}

[Auto] public class CustomWaitUntilTrue {
    public CustomClass Custom = new CustomClass();

    [Auto] IEnumerable OnInitialize(Visual sender) {
        Logger.Log("Waiting for expression to be true.");
        // To test this script use the immediate window, select the visual with the script and enter:
        //    Selection[0].Custom.A = 11
        yield return Wait.UntilTrue(() => Custom.A > 10, Custom);
        Logger.Log("Expression is now true: "+Custom.A);
    }
}
See Also