Beispiel #1
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, string, TargetInstance, CallSettings)
            // Additional: InsertAsync(string, string, TargetInstance, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string         project = "";
            string         zone    = "";
            TargetInstance targetInstanceResource = new TargetInstance();
            // Make the request
            lro::Operation <Operation, Operation> response = await targetInstancesClient.InsertAsync(project, zone, targetInstanceResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = await targetInstancesClient.PollOnceInsertAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }