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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    598 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    555 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X