%%ItemTitle%%

VLF .NET Snap-in Components

VLF .NET Snap-in Components - Developer's Guide
How to get VLF.NET to notify my component when the application is shutting down
Send comments on this topic.

Glossary Item Box

More than likely you will need to do some form of cleaning up when VLF.NET is shutting down, such as closing your database connections or LOpen .NET connections.

When the application is shutting down, the framework manager (VLF.FrameworkManager class) will fire the avApplicationExit event, so all you need to do is to provide your own handler for this event.

 

Below is a modified code fragment from the example in the previous section showing just how to do that.

 

Shutting Down VLF.NET Copy Code
private void DepartmentDetails_avExecute(object sender, EventArgs e)
{
…
Session session = SessionManager.GetInstance("ENG").Session("Session1");
if (!session.Connected)
{
session.ComputerName = "MyServer";
session.Partition = "DEM";
session.LanguageCode = "ENG";
session.PortNumber = 4545;
session.Connect(false, "MyUserName", "MyPassword");
 
this.avManager.avApplicationExit += new System.EventHandler(this.DepartmentDetails_avApplicationExit);
}
…
            }
 
private void DepartmentDetails_avApplicationExit(object sender, EventArgs e)
{
Session session = SessionManager.GetInstance("ENG").Session("Session1");
session.Disconnect();
}
 

Since it is more than likely that you will have to write more than one command handlers or filters, your code will be more maintainable if you create a separate session class that will centrally handles the opening and closing of connections to your server. All your command handlers and filters can then use this new session class without having to worry about opening and closing connections themselves.

 

© LANSA