Application Management

.NET

Listing Applications

The .NET Application Management API is accessible through glue.AppManager.

To get a collection of all available Glue42 enabled applications, use the AwaitApplications() method:

var applications = await glue.AppManager.AwaitApplications();

To get a specific application, use AwaitApplication() and pass a predicate function for finding the desired application:

var app = await glue.AppManager.AwaitApplication(a => a.Name == "appName");

See the .NET Application Management example on GitHub.

Starting Applications

To start an application, use the Start() method of an application instance:

// Get the application.
var app = await glue.AppManager.AwaitApplication(a => a.Name == "appName");

// Start the application.
app.Start();

Application Context

The Start() method accepts a context object (application starting context) as an optional parameter. The following example demonstrates how to create an application context and pass it to the application you want to start:

// Create application context.
var context = AppManagerContext.CreateNew();
context.Set("selectedClient", "3");

// Pass the context when starting the application.
app.Start(context);

Applications Instances

Each Glue42 enabled application may have multiple running instances. Each instance of a .NET application may have multiple windows belonging to that particular instance.

Current Instance

To get a reference to the current instance of your application, use the MyInstance property:

var myAppInstance = glue.AppManager.MyInstance;

Instance Windows

To get a collection of all Glue42 Windows belonging to an application instance, use the Windows property of the application instance:

// Get an application.
var app = await AppManager.AwaitApplication(a => a.Name == "appName");
// Get the windows belonging to the application instance.
var appWindows = app.Instances.FirstOrDefault()?.Windows;

Events

The .NET Application Management API offers methods for monitoring application and instance events - adding/removing applications, starting/stopping instances and more.

Application

To get notified when an application definition has been added, use the ApplicationAdded event:

glue.AppManager.ApplicationAdded += (appManager, appArgs) =>
    {
        var appName = appArgs.Application.Name;
    };

To get notified when an application definition has been removed, use the ApplicationRemoved event:

glue.AppManager.ApplicationRemoved += (appManager, appArgs) =>
    {
        var appName = appArgs.Application.Name;
    };

To get notified when an application definition has been updated, use the ApplicationUpdated event:

glue.AppManager.ApplicationUpdated += (appManager, appArgs) =>
    {
        var appType = appArgs.Applicaton.ApplicationType;
    };

Instance

To get notified when an application instance has been started, use the ApplicationInstanceStarted event:

glue.AppManager.ApplicationInstanceStarted += (appManager, instanceArgs) =>
    {
        var instanceId = instanceArgs.Instance.Id;
    };

To get notified when an application instance has been stopped, use the ApplicationInstanceStopped event:

glue.AppManager.ApplicationInstanceStopped += (appManager, instanceArgs) =>
    {
        var instanceId = instanceArgs.Instance.Id;
    };