windows phone 7 - How to be sure that object with events can be collected? -


i have virtualdatacollection event

virtualdatacollection.itemsloading += virtualdatacollectiononitemsloading; 

i cant unsubscribe inside of event, because can called random amount of times. how sure, instance collected gc? read articles leaking unsubscribed events( this). also, afaik, wrong set

virtualdatacollection.itemsloading = null; 

for now, i'm using

public void onnavigatedfrom()     {         virtualdatacollection.clear();         virtualdatacollection = null;         cleanup();     } 

but enoguh?

edit: hm.. actually, can add

public void onnavigatedfrom()     {         virtualdatacollection.itemsloading -= virtualdatacollectiononitemsloading;         virtualdatacollection.clear();         virtualdatacollection = null;         cleanup();     } 

how sure, instance collected gc?

if you're worried gc side of things , failing collect publishing instance, don't be. there references event publisher event handlers, not other way round.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -