简体   繁体   English

TaskTupleAwaiter vs Task.WhenAll?

[英]TaskTupleAwaiter vs Task.WhenAll?

TaskTupleAwaiter https://github.com/buvinghausen/TaskTupleAwaiter allows us to do TaskTupleAwaiter https://github.com/buvinghausen/TaskTupleAwaiter允许我们做

// For example
// Task<int> t1() { return Task.FromResult(1); }
// Task<string> t2() { return Task.FromResult("a"); }
var (r1, r2) = await (t1(), t2());

How does it compare to the following code?它与以下代码相比如何? (Besides more concise code) (除了更简洁的代码)

var t1task = t1();
var t2task = t2();
// var r1 = await t1task; // Edited one is actually I wanted to ask
// var r2 = await t2task;
await Task.WhenAll(t1task, t2task);  
var r1 = t1task.Result;
var r2 = t2task.Result;

The project hasn't had any update for a while.该项目有一段时间没有任何更新。 I'm wondering if I need to remove it from our repo.我想知道是否需要将其从我们的仓库中删除。

Based on the source code await (t1(), t2()) should be the same as:根据源代码await (t1(), t2())应该是一样的:

var t1task = t1();
var t2task = t2();
await Task.WhenAll(t1task, t2task);  
var r1 = t1task.Result;
var r2 = t2task.Result;

Which should be preferable compared to the original code (now commented out) in the question.与问题中的原始代码(现已注释掉)相比,这应该更可取

The project hasn't had any update for a while.该项目有一段时间没有任何更新。

The source code was updated only 5 month ago, project targets latest released (at the moment of writing) version of .NET - .NET 6. I would say that for smaller projects which does not have a lot of features such maintainability schedule should be just fine, so personally I see no major reason to switch.源代码仅在 5 个月前更新,项目目标最新发布(在撰写本文时)版本 .NET - .NET 6。我会说对于没有很多功能的小型项目,这样的可维护性计划应该很好,所以我个人认为没有重大的理由来切换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM