locked
How to received focus completed event when used RegionsOfInterestControl in media capture operation?

    Question

  • Hi,

    I want to used new class Windows::Media::Devices::RegionsOfInterestControl in Win 8.1 store app.

    The API is work fine. I can set the ROI and do capture operation. But when i want to get focus completed event, it's don't support. I have already try to used SetRegionsAsync(), but the async operation return before focus completed.

    so my question is, is perhaps get the  focus completed event? if yes, how to do it ?

    Thks

    Tuesday, October 8, 2013 7:51 AM

All replies

  • Your actual problem seems to be related to calling SetRegionsAsync, but the async operation return before focus is completed. Why don't you use the task(SetRegionsAsync).then() { // } handler? The code inside the "then" method will run when the SetRegiosAsync completes. Then you don't have to worry about when the function completed.

    Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog, http://aka.ms/t4vuvz

    Wednesday, October 9, 2013 1:09 AM
    Moderator
  • Hi

    Thks,

    Yes, i have already try below code 

    	auto roiControl = m_MediaCapturemgr->VideoDeviceController->RegionsOfInterestControl;
    	create_task(roiControl->ClearRegionsAsync()).then(
    		[this, roiControl, roiVector]()
    	{
    		return roiControl->SetRegionsAsync(roiVector, true);
    
    	}).then([this](task<void> setTask)
    	{
    		try
    		{
    			setTask.get();
    		}
    		catch (COMException^ e)
    		{
    
    		}
    	});

    BUT, the setTask.get() return quickly, and before focus completed. The function will completed before focus operation.

    Wednesday, October 9, 2013 1:44 AM
  • Hi TonyChi,

    Maybe the article shown below is helpful:

    http://msdn.microsoft.com/en-us/library/system.threading.tasks.task_methods.aspx

    Please have a try on setTask.Wait();

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 29, 2013 10:13 AM
    Moderator