PDA

Click to See Complete Forum and Search --> : Class_Terminate doesn't execute when an object is set to nothing?


ExcalibursZone
Jun 3rd, 2001, 01:31 AM
Howdy, I've run into a bit of a problem. I've been in the process of writing a multi-user game. I've embeded sockets in a class module so that each player has their own socket. Now what happens is this: When a player quits, the player object saves player data, closes the socket and then runs KillPlayer, which is a function to set the player object to nothing. Funny thing is, the Class_Terminate Sub never goes off. Which is where I have all the code to set objects within the player object to nothing. I've declared all my objects properly: Public Player As Persona ... Set Player = New Persona ... Set Player = Nothing ... The same with all the objects the player object uses (socket, timer, etc.)

Has anyone run into this problem? Any possible routes for me to fix this?

Thanks in advance.

TheBao
Jun 3rd, 2001, 05:41 PM
The Terminate event isn't triggered if the instances of the form or class were removed from memory because the application terminated abnormally. For example, if your application invokes the End statement before removing all existing instances of the class or form from memory, the Terminate event isn't triggered for that class or form.

Regards,
TheBao

shridharj
Jun 3rd, 2001, 10:31 PM
Hi,

I was also facing the same problem.I was setting object of Activex exe to nothing.which was calling MTS object(dlls).When i kill(remove ref) from activex exe from GUI, it tooks time to call terminate event,b'cos the control was processing the MTS Object.Atlast the control comes to class_terminate.If u find anymore info . pl let me know
:confused:

ExcalibursZone
Jun 3rd, 2001, 11:03 PM
hmm the program is still running, which is why I can tell that the program is running and not calling the class termininate event.

I'm storing this object in a dictionary. When someone quits, the object is removed from the dictionary then it's set to nothing.

Would it make more sense to set it to nothing then remove it from the dictionary? ;)

The program is not terminating abnormally. It's not terminating at all.

capreal26
Jun 5th, 2001, 04:58 PM
Class_terminate will Never be called on Set object = nothing....

set object = nothing only reduces the reference count by one (ref to COM ref counting) and when all the references are destroyed (by means of setting object = nothing or by setting object to another object or by some other automated mechanism).only then the class_terminate is fired.........
this is why probably u r facing the problem.

hope it helps...

capreal26