如何在do while语句中添加if-else条件。如果“responseStatus”为true,我想等待120secs,否则不要做do-while,继续下一个语句。
bool responseStatus;
do
{
//Do Something
responseStatus = IsWaitingForStatus();
} while (if(responseStatus) ? Thread.Sleep(120): do nothing)
答案 0 :(得分:1)
它不是很清楚你想要什么,但听起来你想这样做:
bool responseStatus;
// The first call should wait for a specified timeout
do
{
responseStatus = IsWaitingForStatus();
if(responseStatus)
Thread.Sleep(120)
else
break;
} while (true);