Skip to content

Launcher

The Launcher class, an abstract part of the ByteCobra Updater framework, is designed for launching applications after they have been updated. This abstract class defines a generic interface for starting applications across different platforms. Implementing this class allows for the creation of platform-specific launch strategies while maintaining a consistent interface for application launch. It includes an abstract Platform property to specify the platform for which the launcher is designed, and an abstract method LaunchAsync to implement the actual launching logic.

Example Usage

Here's an example of how to implement a custom Launcher class:

using System.Threading.Tasks;
using ByteCobra.Updater;

namespace ByteCobra.Updater.Launchers
{
    public class MyWindowsLauncher : Launcher
    {
        public override Platform Platform => Platform.StandaloneWindows64;

        public override async Task<bool> LaunchAsync()
        {
            // Implement custom logic to launch an application on Windows
            try
            {
                // Launching logic, e.g., starting a process
                System.Diagnostics.Process.Start("path/to/application.exe");
                return true;
            }
            catch
            {
                // Handle any exceptions that occur during launch
                return false;
            }
        }
    }
}

In this example, WindowsLauncher inherits from Launcher and is specifically designed for launching applications on the Windows platform. It overrides the Platform property to specify Windows 64-bit and provides an implementation for LaunchAsync that includes the logic to start the application, typically by initiating an executable file.

This subclassing approach enables the creation of customized launchers for different platforms, ensuring that applications are launched correctly in their respective environments.