0

I'm using a nuget package that allows interaction with UptimeRobot monitoring service. Unfortunately this package doesn't seem to have a timeout set when using the service therefore the awaitable task goes forever. So I need to do it myself.

And I came up with this:

List<Monitor> monitors = null;

int timeOut = 8000; // 8 seconds
var task = Task.Factory.StartNew (async () => await _client.GetMonitors ());

if(!task.Wait (timeOut))
{
    throw new Exception ();
}
else
{
    monitors = await task.Result;
}

It seems like it should work but it never throws that exception. Why?

Pedro G. Dias
  • 3,162
  • 1
  • 18
  • 30
Vahid Amiri
  • 10,769
  • 13
  • 68
  • 113

0 Answers0