C
C#9mo ago
Davicr(o)

Do event subscribers keep broadcasters alive and vice-versa?

May be a stupid question, but I hadn't thought of this until now. Does an object being subscribed to a broadcaster keep that broadcaster alive when there's no other references to it? What about the opposite, does a subscriber stay alive as long as it's subscribed to another object?
5 Replies
Davicr(o)
Davicr(o)OP9mo ago
Also, what's the best way to test this? I'm struggling to set up a proper test for this, the finalizers don't seem to be called.
Jimmacle
Jimmacle9mo ago
iirc, no to the first and yes to the second because the delegate holds a reference to the subscriber
Davicr(o)
Davicr(o)OP9mo ago
thanks it would be nice to be able to test this, but it's proving difficult
Jimmacle
Jimmacle9mo ago
are you forcing a GC collection?
Davicr(o)
Davicr(o)OP9mo ago
Yeah, no matter what the finalizer is not called
Want results from more Discord servers?
Add your server