If your application is visible (has the main window), then you can activate the running instance by handling the Startup event (in App.xaml and App.xaml.cs files in case of C#):
private void App_Startup( object sender, StartupEventArgs e )
{
var current_process = Process.GetCurrentProcess( );
var other_process = Process.GetProcessesByName( current_process.ProcessName ).FirstOrDefault( p => p.Id != current_process.Id );
if( other_process != null && other_process.MainWindowHandle != IntPtr.Zero )
{
if( IsIconic( other_process.MainWindowHandle ) )
{
ShowWindow( other_process.MainWindowHandle, SW_RESTORE );
}
SetForegroundWindow( other_process.MainWindowHandle );
Shutdown( );
}
}
[DllImport( "user32" )]
static extern bool IsIconic( IntPtr hWnd );
[DllImport( "user32" )]
static extern bool ShowWindow( IntPtr hWnd, int cmdShow );
const int SW_RESTORE = 9;
[DllImport( "user32" )]
static extern bool SetForegroundWindow( IntPtr hWnd );
This code will activate the existing window and will close the new one.
If you know details about Windows programming, you can use process.MainWindowHandle, SendMessage, PostMessage, etc. to transfer some custom messages (e.g. WM_APP+1 or WM_COPYDATA) with information about parameters.