B
Bob Altman
Suppose I have the following code:
' Get a new instance of some class
Dim myWorker As New MyWorker
' Start a long-running operation on a background thread.
dim deleg as new SomeMethodDeleg(AddressOf myWorker.SomeMethod)
deleg.BeginInvoke(...)
' Abandon the object instance
myWorker = Nothing
At this point I would expect my MyWorker object to be eligible for garbage
collection. But it's still busy running code on a background thread. What
happens when the GC runs?
' Get a new instance of some class
Dim myWorker As New MyWorker
' Start a long-running operation on a background thread.
dim deleg as new SomeMethodDeleg(AddressOf myWorker.SomeMethod)
deleg.BeginInvoke(...)
' Abandon the object instance
myWorker = Nothing
At this point I would expect my MyWorker object to be eligible for garbage
collection. But it's still busy running code on a background thread. What
happens when the GC runs?