Skip to main content
Skip Navigation LinksHome  Extending the Spotfire Platform  Common Tasks and Idioms  Spotfire Application  Spotfire Application Event Handler

©Spotfire 2011

Spotfire Application Event Handler

The Spotfire API provides an extension point for creating event handlers associated with the application. The only event currently available fires when the application is started. Its intended usage is to automatically load data or initate a custom workflow. It can also be used to register event handlers for the DocumentChanged event. Such handlers can, for instance, be used to add custom nodes to the document when it is opened.

Define a class inheriting from CustomApplicationEventHandler. Override the OnApplicationInstanceCreated method. The snippet below displays a message box as soon as the application is started:

class MyEventHandler : CustomApplicationEventHandler
{
    protected override void OnApplicationInstanceCreated(AnalysisApplication application)
    {
        base.OnApplicationInstanceCreated(application);

        // Do something with the application ...

        MessageBox.Show("The application has started!");
    }
}

Register the event handler in the add-in class:

class MyAddIn : AddIn
{
    protected override void RegisterApplicationEventHandlers(AddIn.ApplicationEventHandlerRegistrar registrar)
    {
        base.RegisterApplicationEventHandlers(registrar);

        registrar.Register(new MyEventHandler());
    }
}