wabbajack/Wabbajack.Common/AsyncLazy.cs
2021-10-23 10:51:17 -06:00

17 lines
359 B
C#

using System;
using System.Threading.Tasks;
namespace Wabbajack.Common;
public class AsyncLazy<T> : Lazy<Task<T>>
{
public AsyncLazy(Func<T> valueFactory) :
base(() => Task.Factory.StartNew(valueFactory))
{
}
public AsyncLazy(Func<Task<T>> taskFactory) :
base(() => Task.Factory.StartNew(taskFactory).Unwrap())
{
}
}