##// END OF EJS Templates
minor fixes
minor fixes

File last commit:

r72:d67b95eddaf4 v2
r74:c4140283575c v2
Show More
PromiseExtensions.cs
38 lines | 1.0 KiB | text/x-csharp | CSharpLexer
/ Implab / PromiseExtensions.cs
using System.Threading;
namespace Implab {
public static class PromiseExtensions {
public static IPromise<T> DispatchToCurrentContext<T>(this IPromise<T> that) {
var context = SynchronizationContext.Current;
if (context == null)
return that;
var p = new SyncContextPromise<T>(context, that, true);
that.Then(
x => p.Resolve(x),
e => {
p.Reject(e);
return default(T);
}
);
return p;
}
public static IPromise<T> DispatchToContext<T>(this IPromise<T> that, SynchronizationContext context) {
Safe.ArgumentNotNull(context, "context");
var p = new SyncContextPromise<T>(context, that, true);
that.Then(
x => p.Resolve(x),
e => {
p.Reject(e);
return default(T);
}
);
return p;
}
}
}