async void GetEmotions(object sender, object e) { try { var ms = new MemoryStream(); var msFace = new MemoryStream(); await MC.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), ms.AsRandomAccessStream()); await MC.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), msFace.AsRandomAccessStream()); msFace.Position = 0L; ms.Position = 0L; if (String.IsNullOrEmpty(faceAtrributes)) { faceAtrributes = await OxFaceRecognizer.DetectAllAsync(msFace, true, true, true, true); } else if (faceAtrributes != null && faceAtrributes.Length > 0) { try { EmoAttributes = await Oxford.RecognizeReturnAsync(ms); if (EmoAttributes != null && EmoAttributes.Length > 0) { //Remove special characters and provide a valid JSON string txtjsonResult = JSONMergeAndClean(); AgeAndGender.Text = txtjsonResult; //function to be called EventHubHandler x = new EventHubHandler(); x.ehpush(txtjsonResult); } } catch { } } } catch (ObjectDisposedException ex) { var a = ex; } }