WeakRef and embedding controls

I understand that adding control or embedding creates a reference to an object. Then holding a property as a WeakRef to that object doesn’t add any additional pointers. This means that closing the object, will successfully call the object’s destructor method as all references to it are gone.

Instead of embedded an object first, can I create the object as a WeakRef property, and then embed the control in the Window for example, while maintaining only one reference to the object? (so essentially opposite of above)

The result would be the same.

That makes no sense at all…

If you already know that an object is distroyed when it has ONLY WeakRefs… How exactly can you embed it, if it is destroyed first?

I think what’s being asked:

[Edited for logic]

Var cc As New MyContainer // reference count = 1
cc.EmbedWithin(Self, 100, 100, cc.Width, cc.Height) // reference count = 2
dim ww as new Weakref(cc) // reference count = 2
cc.Close // reference count = 1
cc = nil  // reference count = 0,  and now ww.value = nil

If you tried to do it in a different order, it would most likely fail

Var cc As New MyContainer // reference count = 1
dim ww as new Weakref(cc) // reference count = 1
cc = nil // reference count = 0, and the MyContainer would be destructed
ww.value.EmbedWithin(Self, 100, 100, cc.Width, cc.Height) // will fail with a nilObjectException, since ww.value is nil