long expiry = System.currentTimeMillis() + _delay;
long timeLeft;
while (System.currentTimeMillis() < expiry) {
if (_canceled) {
timeLeft = expiry - System.currentTimeMillis();
return new TaskResult(TaskResult.Status.CANCELED, String.valueOf(timeLeft < 0 ? 0
: timeLeft));
}
sleep(50);
}
timeLeft = expiry - System.currentTimeMillis();
return new TaskResult(TaskResult.Status.COMPLETED,
String.valueOf(timeLeft < 0 ? 0 : timeLeft));
}