mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 10:18:27 -04:00
Base for 4.3 work. Split Nadeko.Common into a separate project
This commit is contained in:
19
src/Nadeko.Common/AsyncLazy.cs
Normal file
19
src/Nadeko.Common/AsyncLazy.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
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();
|
||||
}
|
Reference in New Issue
Block a user