December 2019
Intermediate to advanced
528 pages
11h 19m
English
Finally, let's change the event handler to correctly handle the updated methods:
private async void Button_Clicked(object sender, EventArgs e){ var image = await TakePicture(); DisplayedImage.Source = ImageSource.FromStream(() => image.GetStream()); var emotionData = await GetEmotionAnalysis(image.GetStream()); DisplayData(emotionData);}
As you can see, we needed to make our handler async, as we're calling async methods. We're setting the image source by extracting the stream from the result of TakePicture. Finally, we're passing the list of faces that we return from GetEmotionAnalysis over to the DisplayData method.
We now have a functioning application:
If you press the button, you'll see that the emulator lets you know ...