wabbajack/Wabbajack.App.Test/Extensions.cs
2021-10-23 10:51:17 -06:00

40 lines
907 B
C#

using System;
using System.Threading.Tasks;
using Avalonia.Threading;
using Wabbajack.App.Models;
namespace Wabbajack.App.Test;
public static class Extensions
{
public static async Task WaitUntil<T>(this T src, Predicate<T> check, Action? doFunc = null)
{
Dispatcher.UIThread.RunJobs();
while (!check(src))
{
doFunc?.Invoke();
await Task.Delay(100);
}
}
public static async Task WaitForLock(this LoadingLock l)
{
Dispatcher.UIThread.RunJobs();
while (!l.IsLoading)
{
Dispatcher.UIThread.RunJobs();
await Task.Delay(100);
}
}
public static async Task WaitForUnlock(this LoadingLock l)
{
Dispatcher.UIThread.RunJobs();
while (l.IsLoading)
{
Dispatcher.UIThread.RunJobs();
await Task.Delay(100);
}
}
}