mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
20 lines
411 B
C#
20 lines
411 B
C#
#nullable disable
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace NadekoBot.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();
|
|
} |