Article

Making an agile version of a Windows Runtime delegate in C++/WinRT, part 9

The Old New Thing ·The Old New Thing ·Published 2026-07-30 ·5 min read

This 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 IAgile­Object , 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


Discovered 2026-08-02 Source The Old New Thing Archive 2026-08 →