Hasty Briefsbeta

Bilingual

Making an agile version of a Windows Runtime delegate in C++/WinRT, part 1 - The Old New Thing

2 days ago
  • The problem: a C++/WinRT delegate received from an outside source may not be agile, causing issues when invoked from a different COM context.
  • A simple solution is to wrap the delegate in a winrt::agile_ref and then resolve it back to a delegate when invoking, using a lambda function.
  • The provided template function make_agile_delegate captures the agile_ref and calls get() on it with forwarded arguments.
  • The article hints that this is only a partial solution, with more details to come in part 2.