Select item upon entering container

This commit is contained in:
2022-05-24 18:40:24 +02:00
parent 8167909781
commit c08e345c2f
10 changed files with 127 additions and 25 deletions

View File

@@ -0,0 +1,16 @@
namespace FileTime.Core.Extensions;
public static class TaskExtensions
{
public static async Task<T?> AwaitWithTimeout<T>(this Task<T> task, int timeout, T? defaultValue = default)
{
if (await Task.WhenAny(task, Task.Delay(timeout)) == task)
{
return task.Result;
}
else
{
return defaultValue;
}
}
}