
Please consider replacing this error message with the behavior of focusing on the currently running instance of NinjaTrader. That way when the user double-clicks on NinjaTrader wanting to go to NinjaTrader the user is taken to NinjaTrader.
Here is C# that will focus on the currently running instance of NinjaTrader:
bool successfullyAcquiredNinjaTraderMutex;
using (new Mutex(true, "NinjaTrader.exe", out successfullyAcquiredNinjaTraderMutex))
{
if (successfullyAcquiredNinjaTraderMutex)
{
Application.Run(new NinjaTraderMainForm());
}
else
{
IntPtr soleInstanceOfNinjaTrader
= Process.GetProcessesByName("NinjaTrader")[0].MainWindowHandle;
SetForegroundWindow(soleInstanceOfNinjaTrader);
}
}
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr windowHandle);

Comment