user2864740 user2864740 - 2 months ago 30
C# Question

Is there a defined TimeSpan value for "Indefinite"?

In .NET many methods that accept a TimeSpan treat

as an indefinite-wait. This is relatively easy to type and can be defined as such:

static class CaroselsAndSuch {
static readonly TimeSpan IndefiniteWait = TimeSpan.FromMilliseconds(-1);
// etc etc blah bling golden rings

However, this feels like a relatively common situation- Is there a similar 'constant' definition lurking around the core .NET / Task libraries?


Timeout.InfiniteTimeSpan Field

TimeSpan infiniteTimeSpan = Timeout.InfiniteTimeSpan;

A constant used to specify an infinite waiting period, for methods that accept a TimeSpan parameter.