public function main()
    {
        if ($this->countConditions() > 1) {
            throw new BuildException("You must not nest more than one condition into <waitfor>");
        }

        if ($this->countConditions() < 1) {
            throw new BuildException("You must nest a condition into <waitfor>");
        }

        $cs = $this->getIterator();
        $condition = $cs->current();

        $maxWaitMillis = $this->maxWait * $this->maxWaitMultiplier;
        $checkEveryMillis = $this->checkEvery * $this->checkEveryMultiplier;

        $start = microtime(true) * 1000;
        $end = $start + $maxWaitMillis;

        while (microtime(true) * 1000 < $end) {
            if ($condition->evaluate()) {
                $this->processSuccess();
                return;
            }

            usleep($checkEveryMillis * 1000);
        }

        $this->processTimeout();
    }