Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a defined TimeSpan value for "Indefinite"?

In .NET many methods that accept a TimeSpan treat TimeSpan.FromMilliseconds(-1) 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?

like image 552
user2864740 Avatar asked Mar 11 '23 13:03

user2864740


1 Answers

Timeout.InfiniteTimeSpan Field

TimeSpan infiniteTimeSpan = Timeout.InfiniteTimeSpan;

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

like image 100
mybirthname Avatar answered Mar 13 '23 04:03

mybirthname