Skip to content

Plugin Events ​

Want to refresh a list when a plugin loads or show a message when it's enabled? Subscribe to events from IPluginEventService.

Explore the interactive loading flow to step through calls and events, including disabled and failure scenarios.

After initializing your app, try listening for loaded plugins:

csharp
using DryIoc;
using ShadowPluginLoader.WinUI;
using ShadowPluginLoader.WinUI.Args;
using ShadowPluginLoader.WinUI.Services;

var events = DiFactory.Services.Resolve<IPluginEventService>();
events.PluginLoaded += OnPluginLoaded;

void OnPluginLoaded(object? sender, PluginEventArgs e)
{
    System.Diagnostics.Debug.WriteLine($"{e.PluginId}: {e.Status}");
}

e.PluginId identifies the plugin, and e.Status tells you what happened. Use events.PluginLoaded -= OnPluginLoaded when you no longer need the subscription. For UI changes, use the control's DispatcherQueue to return to the UI thread.

Loading and enabled-state events ​

EventWhen it fires
PluginLoadedAfter the plugin loads and finishes Loaded()
PluginEnabledAfter changing from disabled to enabled and finishing Enabled()
PluginDisabledAfter changing from enabled to disabled and finishing Disabled()

Loading doesn't necessarily enable a plugin. A plugin that was disabled during the previous run still loads at startup but stays disabled.

Update and removal events ​

Pay attention to the conditions for these events:

EventWhen it fires
PluginPlanUpgradeWhen you set the plugin's PlanUpgrade=true
PluginUpgradedWhen you set PlanUpgrade=false
PluginPlanRemoveWhen you set PlanRemove=true or call RemovePlugin; UpgradePlugin currently raises it too
PluginRemovedNot yet raised by the default removal workflow

To confirm an update or removal, wait for CheckUpgradeAndRemoveAsync() at the next startup and check the plugin afterward. Don't rely on these events alone for the result.

Use the update and removal methods to schedule operations. Assigning PlanUpgrade or PlanRemove only changes state and sends notifications.