private async Task <IList <TextRecognitionResult> > AnalyzePhoto(MediaFile photo) { try { var stream = photo.GetStream(); var headers = await computerVisionClient.BatchReadFileInStreamAsync(stream); var operationPath = new Uri(headers.OperationLocation); var operationId = operationPath.Segments[operationPath.Segments.Length - 1]; for (int i = 0; i < 5; i++) { await Task.Delay(TimeSpan.FromSeconds(2)); var httpRequestResponse = await computerVisionClient.GetReadOperationResultWithHttpMessagesAsync(operationId); if (httpRequestResponse.Response.IsSuccessStatusCode) { var result = httpRequestResponse.Body; switch (result.Status) { case TextOperationStatusCodes.NotStarted: case TextOperationStatusCodes.Running: break; case TextOperationStatusCodes.Succeeded: return(result.RecognitionResults); case TextOperationStatusCodes.Failed: default: Help.Log.Error("CogServices Error Code Returned"); return(null); } } if (i == 4) { Help.Log.Error("CogServices Timeout"); } } } catch (Exception ex) { Help.Log.Exception(ex); } return(null); }