Click or drag to resize

ParamPassing Class

Handles parameter passing
Inheritance Hierarchy
SystemObject
  Cauldron.XAMLParamPassing

Namespace:  Cauldron.XAML
Assembly:  Cauldron.Win32.WPF.ParameterPassing (in Cauldron.Win32.WPF.ParameterPassing.dll) Version: 3.2.0.1 (3.2.0.1)
Syntax
C#
public static class ParamPassing

The ParamPassing type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberAreOtherInstanceActive
Gets a value that indicates if other instances of the application are already running.
Top
Methods
  NameDescription
Public methodStatic memberBringToFront
Brings the thread that created the specified application into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.

This will only activate the first application instance in the list, if multiple instances are active.

Public methodStatic memberBringToFront(FuncProcess, Boolean)
Brings the thread that created the specified application into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.
Public methodStatic memberConfigure
Configures the parameter passing
Top
Examples
The following code shows an implementation example.

The parameter passing has to be configured in the static main.

[STAThread]
public static void Main(string[] args)
{
    ParamPassing.Configure(args, x =>
    {
        x.IsSingleInstance = true;
        x.ParameterPassedCallback = new Action<string[]>(p =>
        {
            Application.Current.MainWindow.Title = string.Join(" ", p);
        });
    });

    try
    {
        new App().Run(new MainWindow());
    }
    catch (Exception e)
    {
        MessageBox.Show(e.Message);
    }
}

The main window of the application has to add a message hook.

public MainWindow()
{
    InitializeComponent();
    this.Loaded += (s, e) => this.AddHookParameterPassing();
}
See Also