2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 13:33:13 +00:00

New awaiters

This commit is contained in:
2019-12-31 13:23:55 +03:00
parent ed34ae229d
commit c8bec085a4
8 changed files with 181 additions and 11 deletions

View File

@ -6,20 +6,21 @@ using System.Threading.Tasks;
namespace Esyur.Core
{
public class AsyncAwaiter<T> : INotifyCompletion
public class AsyncAwaiter : INotifyCompletion
{
Action callback = null;
AsyncException exception = null;
T result;
object result;
public AsyncAwaiter(AsyncReply reply)
{
reply.Then(x =>
{
this.IsCompleted = true;
this.result = (T)x;
this.result = x;
this.callback?.Invoke();
}).Error(x =>
{
@ -29,7 +30,7 @@ namespace Esyur.Core
});
}
public T GetResult()
public object GetResult()
{
if (exception != null)
throw exception;
@ -47,6 +48,6 @@ namespace Esyur.Core
callback = continuation;
}
}
}