Exemplo n.º 1
0
        /// <summary>Snippet for SubmitJobAsOperationAsync</summary>
        public async Task SubmitJobAsOperationAsync()
        {
            // Snippet: SubmitJobAsOperationAsync(string, string, Job, CallSettings)
            // Additional: SubmitJobAsOperationAsync(string, string, Job, CancellationToken)
            // Create client
            JobControllerClient jobControllerClient = await JobControllerClient.CreateAsync();

            // Initialize request argument(s)
            string projectId = "";
            string region    = "";
            Job    job       = new Job();
            // Make the request
            Operation <Job, JobMetadata> response = await jobControllerClient.SubmitJobAsOperationAsync(projectId, region, job);

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

            // Retrieve the operation result
            Job 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
            Operation <Job, JobMetadata> retrievedResponse = await jobControllerClient.PollOnceSubmitJobAsOperationAsync(operationName);

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