mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
22 lines
547 B
C#
22 lines
547 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Remotely.Shared.Helpers
|
|
{
|
|
public static class TaskHelper
|
|
{
|
|
public static async Task<bool> DelayUntil(Func<bool> condition, TimeSpan timeout, int pollingMs = 10)
|
|
{
|
|
var sw = Stopwatch.StartNew();
|
|
while (!condition() && sw.Elapsed < timeout)
|
|
{
|
|
await Task.Delay(pollingMs);
|
|
}
|
|
return condition();
|
|
}
|
|
}
|
|
}
|