wabbajack/Wabbajack.Common/AsyncLazy.cs
2021-09-27 06:42:46 -06:00

18 lines
407 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())
{
}
}
}