WaitUntilTrue Method (FuncBoolean, INotifyPropertyChanged) |
Namespace: Demo3D.Native
public static ITask UntilTrue( Func<bool> expression, params INotifyPropertyChanged[] observables )
// 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); } }