May 13, 2005
I'm trying to store a GC pointer in non-GC space. How do I do this?
My specific case is this:
SetProp( hWnd, "DWndPtr", this );

What does one do with the 'this'?



May 13, 2005
"Ben Harper" <ben@gls.co.za> wrote in message news:d61vq8$20he$1@digitaldaemon.com...
> I'm trying to store a GC pointer in non-GC space. How do I do this?
> My specific case is this:
> SetProp( hWnd, "DWndPtr", this );
>
> What does one do with the 'this'?

You can pass "this" anyone as long as there always is at least one reference within the GC scanning space. So storing "this" in the hwnd isn't a problem if you also keep a global list of windows around (or something like that). The biggest problem is that some day a compacting GC might be implemented that would move "this" and then your externally-stored pointer would be pointing to the wrong place. The safest thing to do is store "this" in an assoc array indexed by the hWnd.