comparison Implab/Deferred`1.cs @ 251:7c7e9ad6fe4a v3

Prerelease version of RunnableComponent Added draft messaging interfaces Added more more helpers to Xml/SerializationHelpers
author cin
date Sun, 11 Feb 2018 00:49:51 +0300
parents d82909310094
children
comparison
equal deleted inserted replaced
250:9f63dade3a40 251:7c7e9ad6fe4a
1 using System; 1 using System;
2 using System.Diagnostics; 2 using System.Diagnostics;
3 using System.Threading.Tasks;
3 4
4 namespace Implab { 5 namespace Implab {
5 public class Deferred<T> : IResolvable<T> { 6 public class Deferred<T> : IResolvable<T> {
6 readonly Promise<T> m_promise; 7 readonly Promise<T> m_promise;
7 8
43 thenable.Then(this); 44 thenable.Then(this);
44 } catch (Exception err) { 45 } catch (Exception err) {
45 Reject(err); 46 Reject(err);
46 } 47 }
47 } 48 }
49
50 public virtual void Resolve(Task<T> thenable) {
51 if (thenable == null)
52 Reject(new Exception("The promise or task are expected"));
53
54 try {
55 thenable.Then(this);
56 } catch (Exception err) {
57 Reject(err);
58 }
59 }
48 } 60 }
49 } 61 }