sparse-intern-71089
05/25/2021, 4:11 PMenough-garden-22763
05/25/2021, 4:15 PMbored-oyster-3147
05/25/2021, 4:15 PMTask<T>
can implicitly be cast to Task
but if you want to go the other direction you need to know what TResult
is. Because you'd need to do something like if (nonGenericTask is Task<T> genericTask)
Curious what use-case is for a value-less Output<T>
enough-garden-22763
05/25/2021, 4:16 PMenough-garden-22763
05/25/2021, 4:16 PMenough-garden-22763
05/25/2021, 4:17 PMTask
so caller can wait on it). And my lifted version is trying to lift that Task to Output.enough-garden-22763
05/25/2021, 4:17 PMbored-oyster-3147
05/25/2021, 4:19 PMenough-garden-22763
05/25/2021, 4:21 PMApply
version of the same function https://gist.github.com/t0yv0/a9139fd04f28a5d4e8f1cf20909023ae#file-codegen-cs-L22 - let me use Apply
version instead of “lifted” sorry for misplaced jargon 🙂enough-garden-22763
05/25/2021, 4:22 PMbored-oyster-3147
05/25/2021, 4:22 PMenough-garden-22763
05/25/2021, 4:22 PMenough-garden-22763
05/25/2021, 4:23 PMenough-garden-22763
05/25/2021, 4:24 PMbored-oyster-3147
05/25/2021, 4:26 PMTask
? Are consumers still passing something along from that such that it needs to be Output
?enough-garden-22763
05/25/2021, 4:27 PMInput<T>
.enough-garden-22763
05/25/2021, 4:27 PMTask<T> AwaitInput<T>(Input<T> input)
bored-oyster-3147
05/25/2021, 4:27 PMInput<T>
but returns Task
?enough-garden-22763
05/25/2021, 4:27 PMenough-garden-22763
05/25/2021, 4:28 PMbored-oyster-3147
05/25/2021, 4:28 PMawait
the functions that have no results but not the ones that dobored-oyster-3147
05/25/2021, 4:29 PMenough-garden-22763
05/25/2021, 4:31 PMenough-garden-22763
05/25/2021, 4:43 PMenough-garden-22763
05/25/2021, 4:44 PMpublic static Task Apply(FuncWithConstInputApplyArgs? args = null, InvokeOptions? options = null)
{
var promise = new TaskCompletionSource();
args.PlainInput.Apply(t => {
var plainArgs = new FuncWithConstInputArgs
{
PlainInput = t
};
InvokeAsync(plainArgs, options).ContinueWith(t => CopyTaskStateTo(t, promise));
return t;
});
return promise.Task;
}
public static void CopyTaskStateTo(Task t, TaskCompletionSource promise) {
if (t.IsCompletedSuccessfully)
{
promise.SetResult();
}
else if (t.IsFaulted)
{
promise.SetException(t.Exception);
}
else
{
promise.SetCanceled();
}
}
enough-garden-22763
05/25/2021, 4:45 PMOutput<Object>
since users will be wondering what is that and what is the null in there.enough-garden-22763
05/25/2021, 4:45 PMenough-garden-22763
05/25/2021, 4:53 PMenough-garden-22763
05/25/2021, 4:53 PMenough-garden-22763
05/25/2021, 4:55 PMenough-garden-22763
05/25/2021, 4:55 PMbored-oyster-3147
05/25/2021, 4:57 PM