Kunal Chowdhury
Kunal Chowdhury

Reputation: 91

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?

Upvotes: 0

Views: 94

Answers (1)

Memoizer
Memoizer

Reputation: 2289

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

Upvotes: 1

Related Questions