We have found that a very common pattern for event handlers is to capture a weak reference into a lambda, and in the event handler, try to upgrade the weak reference to a strong one, and if so, do some work:
We propose extending the existing delegate constructors to permit a winrt::weak_ref + lambda (or std::weak_ptr + lambda), which simplifies the above to
Version
2.0.230706.1
Summary
We have found that a very common pattern for event handlers is to capture a weak reference into a lambda, and in the event handler, try to upgrade the weak reference to a strong one, and if so, do some work:
We propose extending the existing delegate constructors to permit a
winrt::weak_ref
+ lambda (orstd::weak_ptr
+ lambda), which simplifies the above toReproducible example
No response
Expected behavior
No response
Actual behavior
No response
Additional comments
No response