2021-10-23 16:39:48 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2021-10-23 16:51:17 +00:00
|
|
|
|
2021-10-23 16:39:48 +00:00
|
|
|
public static async Task WaitForUnlock(this LoadingLock l)
|
|
|
|
{
|
|
|
|
Dispatcher.UIThread.RunJobs();
|
|
|
|
while (l.IsLoading)
|
|
|
|
{
|
|
|
|
Dispatcher.UIThread.RunJobs();
|
|
|
|
await Task.Delay(100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|