Making an agile version of a Windows Runtime delegate in C++/WinRT, part 9
cppdashboard.dev/r/2026/08/making-an-agile-version-of-a-windows-runtime-delegate-in-cpp-2This article discusses the challenges faced while creating an agile version of a Windows Runtime delegate in C++/WinRT, particularly focusing on non-marshalable delegates. It compares the implementations of C++/WinRT, C++/CX, and WRL.
From the article
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.
Share this resource