在.NET中,许多接受TimeSpan的方法将TimeSpan.FromMilliseconds(-1)
视为无限期等待。这相对容易打字,可以这样定义:
static class CaroselsAndSuch {
static readonly TimeSpan IndefiniteWait = TimeSpan.FromMilliseconds(-1);
// etc etc blah bling golden rings
然而,这感觉就像一个相对常见的情况 - 核心.NET / Task库周围是否存在类似的“常量”定义?
答案 0 :(得分:6)
Timeout.InfiniteTimeSpan Field
TimeSpan infiniteTimeSpan = Timeout.InfiniteTimeSpan;
用于为方法指定无限等待期的常量 接受TimeSpan参数。