Elastacloud.AzureManagement.Fluent.Commands.Services.ServiceCommand.ResponseCallback C# (CSharp) Method

ResponseCallback() protected method

Initially used via a response callback for commands which expect a async response
protected ResponseCallback ( HttpWebResponse webResponse ) : void
webResponse System.Net.HttpWebResponse the HttpWebResponse that will be sent back to the user from the request
return void
        protected virtual void ResponseCallback(HttpWebResponse webResponse)
        {
            //Track and throw up the X-ms request id (x-ms-request-id)
            MsftAsyncResponseId = webResponse.GetResponseHeader("x-ms-request-id");
               // Trace.WriteLine("Hosted Service Response Id: {0}", MsftAsyncResponseId);
            for (;;)
            {
                var asyncCommand = new GetAsyncStatusCommand
                                       {
                                           HttpVerb = HttpVerbGet,
                                           SubscriptionId = SubscriptionId,
                                           OperationId = MsftAsyncResponseId,
                                           ServiceType = "operations",
                                           Certificate = Certificate
                                       };
                asyncCommand.Execute();
                Thread.Sleep(1000);
                OperationStatus status = asyncCommand.GetOperationStatus();
                switch (status)
                {
                    case OperationStatus.InProgress:
                        break;
                    case OperationStatus.Failed:
                        //Trace.WriteLine(String.Format("Hosted Service Response Id: {0}", MsftAsyncResponseId);
                        _lastFailureResponse = asyncCommand.GetFailureText();
                        SitAndWait.Set();
                        return;
                    case OperationStatus.Succeeded:
                        //Trace.WriteLine("Hosted Service Response Id: {0}", MsftAsyncResponseId);
                        SitAndWait.Set();
                        return;
                }
            }
        }