Click or drag to resize

ITpsViewSetup and ITpsViewActivation

ITpsViewSetup

An application that TAF needs to initialize must have a default (empty) constructor and must implement the interface ITpsViewSetup , which specifies the two methods Install and Uninstall.

Install and Uninstall

Install is called when the application is created in TAF. The parameters are used by TAF and should not be modified. It is recommended to add code for further initiations and allocation of system resources in this method, for example load assemblies, open communication channels, and so on.

When you close the application Uninstall is called. This happens right before the application is deleted. It is recommended to add code for disposal of system resources in this method, for example unload assemblies, close sockets, and so on.

ITpsViewActivation

All custom applications should implement the ITpsViewActivation interface, which specifies the two methods Activate and Deactivate. These are used by TAF to notify applications when they get focus and when they lose it.

Activate and Deactivate

Activate is run every time the application gets focus. This happens at initialization, after the ITpsViewSetup.Install method has been run, and when you click the application icon in the task bar.

Deactivate, accordingly, is run every time the application loses focus. This happens when you close the application, before the ITpsViewSetup.Uninstall method has been run, and when you click another application icon in the task bar.

Note Note

It is recommended to activate and deactivate timers in these methods. This way timers will not run when other applications are in focus, thus saving processor power. For the same reason, any subscription to controller events should be disabled in Deactivate and enabled again in Activate. Note that current values should be read before enabling the subscription.

Simple code examples

This table shows the basic things that the ITpsView methods are used for in a custom application:

Method

Usage

Install

Create the Controller object

C#
aController = new Controller();
VB
AController = New Controller

Activate

Add subscription to controller event:

C#
AController.OperatingModeChanged += new OperatingModeChangedEventHandler(UpdateUI);
VB
AddHandler AController.OperatingModeChanged, AddressOf UpdateUI

Deactivate

Remove subscription to controller event:

C#
AController.OperatingModeChanged -= new OperatingModeChangedEventHandler(UpdateUI);
VB
RemoveHandler AController.OperatingModeChanged, AddressOf UpdateUI

Uninstall

Remove the controller object:

C#
if (aController != null)

{

aController.Dispose();

aController = null;

}
VB
If Not AController Is Nothing Then

AController.Dispose()

AController = Nothing

End If