What happens when an object which has a function currently being executed has all its references removed?
I want to have a dialog box type object held in an array by the main class for my program, and when the dialog needs to be closed, I want it to be removed from the array during that close-screen function. My question is, assuming the dialog box object is in all other ways eligible for garbage collection, what happens to the code it’s supposed to be executing?
Edit for clarification:
The array is a layer of visual elements in my program, of which the dialog box is one. The idea is that the “OK” button (or whatever) that closes the box will also remove it from the array of objects being displayed at the same time.
If all references to the object have been removed while a function of this object is being executed, the rest of the function will keep executing. When it’s done, the object will be removed during the next garbage collection cycle.