Friday, February 1, 2013

Object is not destructing after removing it from the collection

Object is not destructing after removing it from the collection

In Silverlight, I have a collection of tab items. On clicking of a button, I am adding a new tab with a control as content in the collection and showing it to the screen. Now, I have a "Close" button in the screen, calling which, the current visible tab removes from the collection and thus no longer visible in the screen.

I noticed that, though the tab item has been removed from the collection from the tab item and collection, the destructor of the control part of the tab is not getting call all the time. And sometime, it is getting called after a long time (not always).

Though the item has been removed, why it is taking time to call the destructor of the object? How can I resolve this issue? Any pointers?

Answers & Comments...

Answer: 1

The destructor of the object called by Garbage Collector, when it seems necessary. Programmer should not rely on the immediate calling the destructor.

by : Memoizerhttp://stackoverflow.com/users/1937750




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog