1

In my project I have used WeakSubscribe to subscribe the event instead of '+=' operation.

On the other side, is it has the unsubscribe ('-=')?

4

1 回答 1

2

If you subscribe using something like:

     _token = thing.WeakSubscribe(HandleTheEvent);

then you can unsubscribe using:

     _token.Dispose();
     _token = null;

Note that it's important to keep a reference to _token for as long as you want the subscription to last - if the token is garbage collected then the event will also be unsubscribed.

于 2013-11-05T08:01:51.210 回答