"ZorpiedoMan" <(E-Mail Removed)> schrieb
> This is either a bad bug, or I'm not understanding
> somthing. In my mind, this should NOT work:
>
> ------------------------------------------
> Class ShouldntWork
> Delegate Sub goHere()
>
> Sub StartHere()
> Dim DC as new DeadClass
> Dim myDel as New goHere(AddressOf DeadClass.Here)
> DC = Nothing
> GC.Collect
> myDel.Invoke
> End Sub
> End Class
>
> Class DeadClass
> Sub Here
> MsgBox "How Did I Get Here?"
> End Sub
> End Class
> --------------------------------------
>
> I'm assuming that since a delegate is really just a
> pointer to a place in memory, that invoking it still sends
> us there, but isn't this dangerous? Assume that that
> location on the heap has been overwritten, who knows what
> will happen, right?
>
> Comments, Please!
I also think it should not work: "Here" is not a shared method, so it should
be "...addresof dc.here".
Apart from this, it _should_ work because the delegate still points to the
DC object => there is still a reference to the object => The object is not
collected.
--
Armin
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html