I have code which gets the photo from a web camera. I need to write a mechanism that would be expected to complete this process. How do I do this? I have the following code:
ImageEncodingProperties imageProperties = ImageEncodingProperties.CreateJpeg();
var memStream3 = new Windows.Storage.Streams.InMemoryRandomAccessStream();
var mediaCaptureMgr1 = new MediaCapture();
await mediaCaptureMgr1.InitializeAsync();
mediaCaptureMgr1.SetPreviewMirroring(true);
await mediaCaptureMgr1.CapturePhotoToStreamAsync(imageProperties, memStream3);
await memStream3.FlushAsync();
memStream3.Seek(0);
WriteableBitmap wb1 = new WriteableBitmap(320, 240);
wb1.SetSource(memStream3);
//1
while (true)
{
await Task.Delay(TimeSpan.FromSeconds(0.1));
//if CapturePhotoToStreamAsync finished? OR memStream3 not null?
//break;
}
//2
If I start to do anything with wb1 at //1, I will not work because wb1 = null. If I start doing it at //2 the wb1! = null because I waited until all the async function are completed.
while-loop?whileloop in there at all. I also don't understand what you are asking. Please be more specific here...CapturePhotoToStreamAsyncmethod, the method already finished in the followed code line. That's the point of using await.