Exemplo n.º 1
0
        /// <summary>
        /// Waits for deployment operation.
        /// </summary>
        /// <param name="caasId">The CaaS identifier.</param>
        /// <returns>The async <see cref="Task"/>.</returns>
        private async Task <JObject> WaitForDeploy(string caasId)
        {
            DateTime startTime = DateTime.Now;

            while (true)
            {
                if ((DateTime.Now - startTime).TotalMinutes >= PollingTimeOutMinutes)
                {
                    throw new TimeoutException(String.Format(
                                                   "Timed out waiting to create {0} with id {1}", _resourceType, caasId));
                }

                var props = await Get(caasId);

                if (props["state"].Value <string>() == "NORMAL")
                {
                    _logProvider.CompleteProgress();
                    return(props);
                }
                _logProvider.IncrementProgress();
                await Task.Delay(TimeSpan.FromSeconds(PollingDelaySeconds));
            }
        }