Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

IShutdownTask

Describes shutdown task purposes and examples.

Method

void Run();

Executes the shutdown task.

Remarks

Shutdown tasks are used to clean up resources used by the Commerce (SaaS) application that are not native to ASP.NET web applications, such as timers created and used by Commerce (SaaS). These tasks run during the standard Application_End event. They do not run in any configured order.

Example: Stop timer watching for theme updates in GitHub

This shutdown task stops the timers created and started during the application boot process. These timers monitor the repository attached to a theme source. If the repository contains any new changes, those changes will be pulled from the repository into a theme in Commerce (SaaS).

public class ThemeSourceWatcherShutdownTask : IShutdownTask
{
    public void Run()
    {
        var themeSourceWatcher = DependencyLocator.Current.GetInstance<IThemeSourceWatcher>();
        themeSourceWatcher.StopThemeSourceWatcher();
    }
}