COM Add-In: Close Instance?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

cazeek
Posts: 5
Joined: Sat Feb 23, 2019 1:00 pm

COM Add-In: Close Instance?

Postby cazeek » Sat Feb 23, 2019 4:58 pm

Hello,

Is there a way to close the instance of E-Views through the COM automation? Something like app.Close?

Thanks!

cazeek
Posts: 5
Joined: Sat Feb 23, 2019 1:00 pm

Re: COM Add-In: Close Instance?

Postby cazeek » Sat Feb 23, 2019 5:00 pm

Nevermind- after spending 30 min trying to figure this out, got it just as I posted (of course)...

app.Run("exit")

EViews Steve
EViews Developer
Posts: 798
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: COM Add-In: Close Instance?

Postby EViews Steve » Mon Feb 25, 2019 8:44 am

Actually, running the EXIT command via COM can potentially cause problems with your COM objects in your application. You're asking EViews to shutdown, even though you still have an EViews Application object in your program and if you try to use that object again afterwards you'll most definitely get an exception.

The lifetime of a COM server (such as EViews) follows the basic rule that if anyone is using the application, it remains up and running. So any application objects you have in your application counts as a "user" -- and multiple variables counts as multiple "users". One special rule about this is that if the EViews application window is itself visible, that also counts as a "user". So, if you launch EViews via COM, and then call the Show method to make the application itself visible, and then your program shuts down, EViews will remain running since the application window is being shown and there might be a desktop user using it that way.

Hide EViews before your Program Ends
So the proper way to make sure EViews shuts down after you're done with it is to make sure the EViews application window is NOT visible when your program ends (by calling Application::Hide). Then once your program has released all EViews object references (namely the Application object), EViews will shutdown (usually within a few seconds).

NOTE: In some languages (such as .NET), the destruction of an object reference is handled by a separate garbage collector that runs in its own thread/process. This can cause a significant delay between clearing your last application object variable (such as setting it to null or Nothing) and seeing EViews shutdown. In these cases, your development environment might allow you to call explicitly call the garbage collector to run immediately and speed up this process.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 16 guests