diff 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
line wrap: on
line diff
--- a/Implab/Deferred`1.cs	Thu Feb 01 02:43:35 2018 +0300
+++ b/Implab/Deferred`1.cs	Sun Feb 11 00:49:51 2018 +0300
@@ -1,5 +1,6 @@
 using System;
 using System.Diagnostics;
+using System.Threading.Tasks;
 
 namespace Implab {
     public class Deferred<T> : IResolvable<T> {
@@ -45,5 +46,16 @@
                 Reject(err);
             }
         }
+
+        public virtual void Resolve(Task<T> thenable) {
+            if (thenable == null)
+                Reject(new Exception("The promise or task are expected"));
+            
+            try {
+                thenable.Then(this);
+            } catch (Exception err) {
+                Reject(err);
+            }
+        }
     }
 }
\ No newline at end of file