Making an agile version of a Windows Runtime delegate in C++/WinRT, part 2 - The Old New Thing
12 hours ago
- The function now checks if a delegate is already agile by looking for the IAgileObject interface before wrapping it.
- If the delegate has the IAgileObject marker, it returns the original delegate without an agile wrapper.
- If not agile, the function creates an agile wrapper using winrt::agile_ref for cross-apartment use.
- Attempting copy elision by passing the delegate by value doesn't work because function parameters are not eligible for copy elision.