Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 17974
Number of posts: 55343

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to destry an object from its own code Posted by Cheeko on 17 Jun 2010 at 12:31 PM
Dear friends,

I have a question, I dont know how to do this.

A have written an activex exe (let say FileCopy.exe. I want that obect itself can be destroyed from the class.

suppose an application creates a component from the class "FileCopy"

Set NewFile =CreateObject ("FileCopy.Filops")

Is it possbile the application quits and object is still running in separate space and We can destry it (Filops) based on certain condition (let say timeout) from its own code (Filops).

A form is placed in the class. A timer control is on the form. Once the object is created the form is loaded and timer starts after the 15 seconds object should destroy itself. Client application which creates the file terminates just after the creation of object like



Set NewFile=CreateObject("FileCopy.Filops")

End

Any idea

Report
Re: How to destry an object from its own code Posted by BitByBit_Thor on 20 Jun 2010 at 7:24 AM
It's not possible for an Object to destroy itself.

However, as soon as there are no more references to the object it will be automatically destroyed by the garbage collection system VB employs.
In VB6 this is the instant the last reference is released.

In your case, as soon as NewFile is set to Nothing, or goes out of scope (and assuming you haven't stored the reference in other variables). Your app terminating will cause this to happen.

So in other words, what you want already happens.
Best Regards,
Richard

The way I see it... Well, it's all pretty blurry



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.