You can put it off several times. For example:
static async Task LongDelay(long milliseconds) { if (milliseconds < 0) { throw new ArgumentOutOfRangeException(); } if (milliseconds == 0) { return; } int iterations = (milliseconds - 1) / int.MaxValue; while (iterations-- > 0) { await Task.Delay(int.MaxValue); milliseconds -= int.MaxValue; } await Task.Delay(milliseconds); }
However, int.MaxValue milliseconds is a really long time, almost 25 days! IMHO a much more important question, is the Task.Delay() method really the best solution for your scenario? Knowing more about why you are trying to wait for such a long period of time can help others offer you a better solution to a real problem, instead of solving this specific need.
Peter Duniho
source share