Call MediaCapture.InitializeAsync from UWP BackgroundTask

2

I am trying to take a photo during a BackgroundTask at an UWP application. I read at documentation that InitializeAsync should be on the STA thread but is there some approach to achieve that from a MTA? I don't known, something like Dispatchers or others workarounds.

In my actual scenario, when I call CapturePhotoToStreamAsync just after the InitializeAsync, the following exception occurs:

System.Runtime.InteropServices.COMException (0xC00D3E82): A media source cannot go from the stopped state to the paused state.

The funny thing is that it works if my app is not suspended.

c#
windows-10
uwp
windows-10-universal
background-task
asked on Stack Overflow Jan 31, 2016 by P. Ted

1 Answer

2

I don't think you will get it to work in BackgroundTask - as MSDN says:

InitializeAsync should be called from the main UI thread of your app. For more information, see Guidelines for enabling sensitive devices.

answered on Stack Overflow Feb 1, 2016 by Romasz

User contributions licensed under CC BY-SA 3.0