Mercurial > pub > ImplabNet
view Implab/PromiseAwaiter.cs @ 244:eee3e49dd1ff v3
working on promises
author | cin |
---|---|
date | Thu, 25 Jan 2018 19:09:16 +0300 |
parents | cbe10ac0731e |
children |
line wrap: on
line source
using System; using System.Runtime.CompilerServices; namespace Implab { public struct PromiseAwaiter : INotifyCompletion { readonly IPromise m_promise; public PromiseAwaiter(IPromise promise) { m_promise = promise; } public void OnCompleted (Action continuation) { if (m_promise != null) m_promise.On(continuation, PromiseEventType.All); } public void GetResult() { m_promise.Join(); } public bool IsCompleted { get { return m_promise.IsFulfilled; } } } }