mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
19 lines
390 B
C#
19 lines
390 B
C#
using System.Runtime.CompilerServices;
|
|
|
|
namespace Nadeko.Common;
|
|
|
|
public class AsyncLazy<T> : Lazy<Task<T>>
|
|
{
|
|
public AsyncLazy(Func<T> valueFactory)
|
|
: base(() => Task.Run(valueFactory))
|
|
{
|
|
}
|
|
|
|
public AsyncLazy(Func<Task<T>> taskFactory)
|
|
: base(() => Task.Run(taskFactory))
|
|
{
|
|
}
|
|
|
|
public TaskAwaiter<T> GetAwaiter()
|
|
=> Value.GetAwaiter();
|
|
} |