public resultAndBladeName waitForSuccess(resultAndBladeName res, TimeSpan timeout)
        {
            resultAndBladeName toRet = waitForSuccessWithoutThrowing(res, timeout);

            if (toRet == null)
            {
                throw new TimeoutException();
            }

            if (toRet.result.code == resultCode.success ||
                toRet.result.code == resultCode.noNeedLah)
            {
                return(toRet);
            }

            throw new Exception("Unexpected status during .getProgress: " + res.result.code + " / " + res.result.errMsg);
        }
        public resultAndBladeName waitForSuccessWithoutThrowing(resultAndBladeName res, TimeSpan timeout)
        {
            DateTime deadline = DateTime.Now + timeout;

            while (true)
            {
                switch (res.result.code)
                {
                case resultCode.pending:
                    if (DateTime.Now > deadline)
                    {
                        return(null);
                    }
                    res = (resultAndBladeName)this.svc.getProgress(res.waitToken);
                    break;

                default:
                    return(res);
                }
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }
        }