I have a C ++ WinRT component which is WinRtClassicComMix. I want to define a method that returns a custom class through IAsyncOperation for calling C # or WinJS code. Everything works fine when IAsyncAction is used without a return value, but using the PPL create_async with an automatically return value is issued by the VS 2012 and VS 2013 compiler.
Relevant details:
Interfaces and classes are defined in the IDL:
namespace MyControl
{
runtimeclass MyComponentColorTable;
[version(MyS_VERSION)]
[uuid(7BB5A348-C82C-4EC4-946F-5113843A6A83)]
[exclusiveto(MyComponentColorTable)]
interface IMyComponentColorTable: IInspectable
{
[propget] HRESULT Count([out, retval] unsigned long *value);
HRESULT GetAt([in] unsigned long index, [out, retval] ComponentColor *componentColor);
}
[version(MyS_VERSION)]
[activatable(MyS_VERSION)]
[marshaling_behavior(agile)]
[threading(both)]
runtimeclass MyComponentColorTable
{
[default] interface IMyComponentColorTable;
}
runtimeclass MyRendererScene;
[version(MyS_VERSION)]
[uuid(8D51F7F2-EDCF-4ED4-B556-03D3CC390A83)]
[exclusiveto(MyRendererScene)]
interface IMyRendererScene: IInspectable
{
HRESULT GetComponentColorTableAsync([in] GUID assetId, [out, retval] Windows.Foundation.IAsyncOperation<MyControl.MyComponentColorTable*>** operation);
}
}
Relevant header file:
class CMyRendererScene :
public Microsoft::WRL::RuntimeClass
<
RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix>,
IMyRendererScene
>
{
InspectableClass(RuntimeClass_MyControl_MyRendererScene, BaseTrust);
public:
CMyRendererScene(void);
~CMyRendererScene(void);
IFACEMETHOD(GetComponentColorTableAsync)(GUID assetId, ABI::Windows::Foundation::IAsyncOperation<ABI::MyControl::MyComponentColorTable*>** operation);
};
And CPP:
IFACEMETHODIMP CMyRendererScene::GetComponentColorTableAsync(GUID assetId, ABI::Windows::Foundation::IAsyncOperation<ABI::MyControl::MyComponentColorTable*>** operation)
{
Concurrency::task_completion_event<ABI::MyControl::MyComponentColorTable*> tce;
auto tsk = Concurrency::create_task(tce);
auto asyncOp = Concurrency::create_async( [tsk]() -> Concurrency::task<ABI::MyControl::MyComponentColorTable*>
{
return tsk;
});
return S_OK;
}
Compiling this fails with the VS C ++ compiler failing:
Error 1 Error C1001: An internal error occurred in the compiler. c: \ program files (x86) \ Microsoft Visual Studio 11.0 \ vc \ include \ ppltasks.h 5513 1 MyControl
- , create_async asyncOp. , .:( , , ABI:: MyControl:: MyComponentColorTable * ^, WinRT, , create_async , WinRT IAsyncOperation ? MyComponentColorTable, WinRT? IAvatarComponentColorTable , [exclusiveto (AvatarComponentColorTable)].:(