Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unhandled Exception with Custom Add-OnCross-thread Operation

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

    Unhandled Exception with Custom Add-OnCross-thread Operation

    I’ve been developing a custom add-on that uses multiple threads to handle real-time data processing. However, I keep running into a 'Cross-thread operation not valid' error when trying to update UI components from a background thread. I’m aware this might be related to NinjaTrader’s threading model, but I’m unsure how to properly implement a solution to safely interact with UI components from a non-UI thread. Any guidance on handling NinjaTrader's thread safety model in custom add-ons?

    #2
    Hello mukeshbhardwaj,

    Welcome to the NinjaTrader forums!

    Custom threading is an advanced C# concept and is not fully supported by the Scripting Support team.

    There can be limitations using unsupported code and advanced C# concepts in a NinjaScript, so your mileage may vary. As of now, we do not have any examples that can be used to navigate that path.​


    That said, be sure you are using on object's dispatcher with <object>.Dispatcher.Invoke.Async().
    Help guide: NinjaScript > Educational Resources > Multi-Threading Consideration for NinjaScript​
    Help guide: NinjaScript > NinjaScript Best Practices​ > Error handling practices > Modifying UI elements and multi-threading
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sjsj2732, Today, 04:31 AM
    0 responses
    20 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    280 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    279 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    130 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    90 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X