コード例 #1
0
        /// <summary>Snippet for AsyncBatchAnnotateImagesAsync</summary>
        public async Task AsyncBatchAnnotateImagesAsync()
        {
            // Snippet: AsyncBatchAnnotateImagesAsync(IEnumerable<AnnotateImageRequest>, OutputConfig, CallSettings)
            // Additional: AsyncBatchAnnotateImagesAsync(IEnumerable<AnnotateImageRequest>, OutputConfig, CancellationToken)
            // Create client
            ImageAnnotatorClient imageAnnotatorClient = await ImageAnnotatorClient.CreateAsync();

            // Initialize request argument(s)
            IEnumerable <AnnotateImageRequest> requests = new AnnotateImageRequest[]
            {
                new AnnotateImageRequest(),
            };
            OutputConfig outputConfig = new OutputConfig();
            // Make the request
            Operation <AsyncBatchAnnotateImagesResponse, OperationMetadata> response = await imageAnnotatorClient.AsyncBatchAnnotateImagesAsync(requests, outputConfig);

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

            // Retrieve the operation result
            AsyncBatchAnnotateImagesResponse 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 <AsyncBatchAnnotateImagesResponse, OperationMetadata> retrievedResponse = await imageAnnotatorClient.PollOnceAsyncBatchAnnotateImagesAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                AsyncBatchAnnotateImagesResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
コード例 #2
0
        /// <summary>Snippet for AsyncBatchAnnotateImages</summary>
        public void AsyncBatchAnnotateImages_RequestObject()
        {
            // Snippet: AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest,CallSettings)
            // Create client
            ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.Create();
            // Initialize request argument(s)
            AsyncBatchAnnotateImagesRequest request = new AsyncBatchAnnotateImagesRequest
            {
                Requests     = { },
                OutputConfig = new OutputConfig(),
            };
            // Make the request
            Operation <AsyncBatchAnnotateImagesResponse, OperationMetadata> response =
                imageAnnotatorClient.AsyncBatchAnnotateImages(request);

            // Poll until the returned long-running operation is complete
            Operation <AsyncBatchAnnotateImagesResponse, OperationMetadata> completedResponse =
                response.PollUntilCompleted();
            // Retrieve the operation result
            AsyncBatchAnnotateImagesResponse 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 <AsyncBatchAnnotateImagesResponse, OperationMetadata> retrievedResponse =
                imageAnnotatorClient.PollOnceAsyncBatchAnnotateImages(operationName);

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