与https://github.com/louthy/language-ext绑定任务需要返回类型(Task<>)的任务。因此,没有返回类型的任务应该转换为Task<Unit>。
有谁知道在C#中将Task转换为Task<Unit>的紧凑(仅限表达式)方法-使用(或不使用)使用Language-Ext?
换句话说:有没有类似于Task的fun(...)
发布于 2018-09-04 00:30:19
我现在不能测试它,但它应该可以做你想要的。
public static class TaskExtensions
{
public static async Task<Unit> ToUnit(this Task task)
{
await task;
return unit;
}
}然后调用:
task.ToUnit();在你的未输入任务上。我可能会在某个时刻将其添加到lang-ext中。
https://stackoverflow.com/questions/52151267
复制相似问题