mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 19:42:58 +00:00
41 lines
791 B
C#
41 lines
791 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
|
|
namespace Esiur.Engine
|
|
{
|
|
public class AsyncAwaiter<T> : INotifyCompletion
|
|
{
|
|
Action callback = null;
|
|
T result;
|
|
private bool completed;
|
|
|
|
public AsyncAwaiter(AsyncReply<T> reply)
|
|
{
|
|
reply.Then(x =>
|
|
{
|
|
completed = true;
|
|
result = x;
|
|
callback?.Invoke();
|
|
});
|
|
}
|
|
|
|
public T GetResult()
|
|
{
|
|
return result;
|
|
}
|
|
|
|
public bool IsCompleted => completed;
|
|
|
|
//From INotifyCompletion
|
|
public void OnCompleted(Action continuation)
|
|
{
|
|
Console.WriteLine("Continue....");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|