P. Ted
P. Ted

Reputation: 71

Call MediaCapture.InitializeAsync from UWP BackgroundTask

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.

Upvotes: 2

Views: 1099

Answers (1)

Romasz
Romasz

Reputation: 29790

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.

Upvotes: 3

Related Questions