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