Quantcast
Channel: MVVM Light Toolkit
Viewing all articles
Browse latest Browse all 1826

Edited Issue: WeakAction issue for WinRT version [7614]

$
0
0
The implementation of `WeakAction` for WinRT doesn't work, since the target‘s hard reference is kept by the member `Action` object itself. as follow code:

```
public WeakAction(object target, Action action)
{
if (target != null)
{
_reference = new WeakReference(target);
}

_action = action; // The hard reference of target still exsits.
}
```

This issue has been spread to `RelayCommand` that uses the `WeakAction` for implementation.
It's easy to reproduce this issue. In winrt app, you can make a cycle reference though a lambda with 'this' as target and use `WeakAction` to replace with `Action`. you will find it really doesn't work.
I didn't test the `WeakFunc` class, but according the same implementation, it maybe have the same issue.

Viewing all articles
Browse latest Browse all 1826

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>