[MS] Making an agile version of a Windows Runtime delegate in C++/WinRT, part 9 - devamazonaws.blogspot.com
Over half of the time we spent trying to make an agile version of a Windows Runtime delegate in C++/WinRT was dealing with the case of a delegate that declares non-marshalability . But how much does it matter? I looked at the three major C++ implementations of the Windows Runtime: C++/WinRT, C++/CX, and WRL. The C++/WinRT implementation has an optimization for IAgileObject , but for objects that aren't agile, it just goes directly to agile_ ref without checking for INoMarshal . This means that a delegate that declares non-marshability will always be rejected by C++/WinRT when used as an event handler. The C++/CX implementation lazy-creates the agile reference to the original delegate when the wrapper is used from a different apartment . If the original delegate is non-marshalable, it means that the CO_ E_ NOTSUPPORTED is produced only when the wrapper is used in a way that requires a marshalable delegate. The WRL implementation does not have an optimization for IAgileO...