In the simplest case the following function might be used:
public static bool Wait(Func<bool> condition, int timeout)
{
var end = DateTimeOffset.UtcNow.Add(TimeSpan.FromMilliseconds(timeout));
while (DateTimeOffset.UtcNow < end)
{
if (condition()) return true;
Thread.Sleep(200);
}
return false;
}
Timeout variable defines here only the maximum timeout, if the condition is true, the execution will immediately continue (well, ok, it might take up to 200 ms :smileyhappy:).
The call of the function might be something like:
if (!WaitHelper.Wait(() => UIMap.OpenButton.Enabled && UIMap.MachineComboBox.Enabled)
{
Assert.Fail("After import the nesting properties are not loaded sucessfully");
}
Hope this helps.