2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 13:33:13 +00:00
This commit is contained in:
2019-08-07 05:18:27 +03:00
parent 2caae61910
commit 8d06fd05ad
74 changed files with 2302 additions and 1336 deletions

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace Esiur.Core
{
public class AsyncAwaiter<T> : INotifyCompletion
{
public Action callback = null;
public T result;
private bool completed;
public AsyncAwaiter(AsyncReply<T> reply)
{
reply.Then(x =>
{
this.completed = true;
this.result = x;
this.callback?.Invoke();
});
}
public T GetResult()
{
return result;
}
public bool IsCompleted => completed;
public void OnCompleted(Action continuation)
{
// Continue....
callback = continuation;
}
}
}