0 votes
by (2.5k points)

If I use Task.Delay for an extremely long time, for example a full day like so : 

await Task.Delay(TimeSpan.FromDays(1));

Is there issues with this? e.g. Will my application crash or something?

1 Answer

0 votes
by (2.5k points)
The short answer is no, Task.Delay can take up to int.MaxValue (in milliseconds), so delaying a day is OK.

However one thing to note is that depending on your application, it may be restarted in other ways. For example if this is a background task with ASP.NET Core, then you might redeploy your application meaning your Task.Delay gets reset (Or your process runs again and then starts the delay all over again).
Welcome to .NET Q&A, where you can ask questions and receive answers from other members of the community.
...