Issue
With the addition of async / await to TypeScript using Promise(s) can look very syntactically close to Task(s).
Example:
Promise (TS)
public async myAsyncFun(): Promise<T> {
let value: T = await ...
return value;
}
Task (C#)
public async Task<T> MyAsyncFun() {
T value = await ...
return value;
}
I was wondering if the other way around, there was an equivalent to .then() for Task(s).
Example:
Promise (TS)
Promise<T> promise = ...
promise.then((result: T) => ...do something...);
Solution
I've used ContinueWith
which can work if you have one or multiple Tasks running.
example:
public async Task<T> MyAsyncFun() {
T value = await ...
return value;
}
MyAsyncFun().ContinueWith(...
https://msdn.microsoft.com/en-us/library/dd270696(v=vs.110).aspx
Answered By - jdmdevdotnet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.