wabbajack/Wabbajack.Common/AsyncLazy.cs

17 lines
359 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System;
using System.Threading.Tasks;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Common;
public class AsyncLazy<T> : Lazy<Task<T>>
{
2021-10-23 16:51:17 +00:00
public AsyncLazy(Func<T> valueFactory) :
base(() => Task.Factory.StartNew(valueFactory))
{
2021-10-23 16:51:17 +00:00
}
2021-10-23 16:51:17 +00:00
public AsyncLazy(Func<Task<T>> taskFactory) :
base(() => Task.Factory.StartNew(taskFactory).Unwrap())
{
}
2021-09-27 12:42:46 +00:00
}