Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Please consider replacing the "There only can be one instance of NinjaTrader" error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Please consider replacing the "There only can be one instance of NinjaTrader" error

    I find the current "Error There only can be one instance of NinjaTrader running at a time (NinjaTrader/2)." error message and subsequent paragraph to be a bit jarring:



    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:
    Code:
    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);

    #2
    Thanks for the suggestion and for kindly providing code sample.
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    237 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    152 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    163 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    246 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    199 views
    0 likes
    Last Post CarlTrading  
    Working...
    X