我正在使用以下代码:
do
{
response = client.GetAsync(jobStatusURI).Result;
if (response.IsSuccessStatusCode)
{
coverageResult = response.Content.ReadAsStringAsync().Result;
if (string.IsNullOrEmpty(coverageResult))
{
int sleepTime = 3000; // Millisecond initialized
System.Threading.Thread.Sleep(sleepTime);
LogAll.LogInfo($"Waiting for job result, sleeping for : {sleepTime}", log);
}
else
return coverageResult;
}
else
{
LogAll.LogError($"Failed to get result", log);
break;
}
} while (string.IsNullOrEmpty(coverageResult));
如果您看到我将睡眠时间设置为3000毫秒,但实际上它睡眠了30秒,即30,000。这是日志
INFO 2019-02-28 14:55:12 –等待工作结果,睡觉:3000
INFO 2019-02-28 14:55:42 –等待工作结果,等待时间:3000
INFO 2019-02-28 14:56:12 –等待工作结果,等待时间:3000
INFO 2019-02-28 14:56:42 –等待工作结果,等待时间:3000
INFO 2019-02-28 14:57:12 –等待工作结果,睡觉:3000
INFO 2019-02-28 14:57:42 –等待工作结果,睡觉:3000
INFO 2019-02-28 14:58:12 –等待工作结果,睡觉:3000
INFO 2019-02-28 14:58:42 –等待工作结果,睡觉:3000
INFO 2019-02-28 14:59:12 –等待工作结果,睡觉:3000
INFO 2019-02-28 14:59:42 –等待工作结果,等待时间:3000