Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default timeout for Task.Wait

Tags:

c#

I have created a web application that uses Task.Wait. Soon after I used it my application slowly came to a crawl about 30 days later. I never found out why but I am suspecting it is the Task.Wait method that never time out if the remote server never response. Just wanted to know if Task.Wait is executed will it wait forever it remote server never response?

like image 620
Luke101 Avatar asked Dec 07 '25 07:12

Luke101


1 Answers

Looking at the source from Reference Source, this if the code from Task.Wait() :

public void Wait()
{
#if DEBUG
    bool waitResult =
#endif
    Wait(Timeout.Infinite, default(CancellationToken));

#if DEBUG
    Contract.Assert(waitResult, "expected wait to succeed");
#endif
}

So, the timeout is Timeout.Infinite!

like image 134
Philippe Paré Avatar answered Dec 08 '25 21:12

Philippe Paré