mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
40 lines
924 B
C#
40 lines
924 B
C#
|
using System;
|
||
|
using System.Threading.Tasks;
|
||
|
using Avalonia.Threading;
|
||
|
using ReactiveUI;
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|