Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chartcontrol.Invalidate Visual different thread owns error

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

    Chartcontrol.Invalidate Visual different thread owns error

    ChartControl.InvalidateVisual() seems to update the charts faster than ForceRefresh, but I'm getting an error while using saying that a different thread owns it.

    1. Is it possible to make ForceRefresh update faster?
    2. What thread does ChartControl.InvalidateVisual() run on and how do I access it to do the proper update?

    #2
    Hello habibalex,

    As noted in the help guide article for ForceRefresh, using Invalidate should not be used for this specific reason: http://ninjatrader.com/support/helpG...orce%2Brefresh

    Instead, you would either need to "queue" a refresh with ForceRefresh, or complete an action that would force the chart to re-render like removing a drawing object. You can locate all the reasons a chart will forcibly refresh on the ForceRefresh help guide page.

    One item that is fairly simple would be to add a dummy drawing object and then remove it right after adding it. For example:

    Code:
    Draw.Dot(this, "dummy", false, 0, Low[0], Brushes.Red);
    RemoveDrawObject("dummy");
    I look forward to being of further assistance.

    Comment


      #3
      By using the dummy object, can I get updates faster than 250 ms?

      Comment


        #4
        Hello habibalex,

        Technically speaking yes, I tried putting this on a timer but this is certainly not a good way update the chart over and over quickly.

        Not only would you be invoking rendering for the entire panel, you would be invoking DrawObject logic to both add and remove the object over and over. Considering the chart already renders at fixed intervals and for specific events, this would be a lot of CPU work to add for the little change. In my tests, I had used 30ms and had seen near 100% CPU use on a single chart, that would not be good for any situation.

        Because this would take a heavy toll on the CPU it could cause problems, I would not recommend it for any type of force rendering in a loop or timer. Removing a draw object to refresh should be left to more targeted uses like clicking a button to update some data on the chart. I could see that this may be visually beneficial but this would not be an efficient way to invoke a faster render than the platform targets.

        I look forward to being of further assistance.

        Comment


          #5
          tbRender 00:00:00.4691424 force 00:00:00.3105562
          forcing 36500:00:00.6130000
          forcing 36500:00:00.2150000
          tbRender 00:00:00.6864239 force 00:00:00.1689801
          forcing 36500:00:00.5110000
          forcing 36500:00:00.1410000
          tbRender 00:00:00.8269360 force 00:00:00.3439161
          forcing 36500:00:00.4340000
          forcing 36500:00:00.1010000
          forcing 36500:00:00.1020000
          tbRender 00:00:00.5176778 force 00:00:00.2245939
          tbRender 00:00:00.0115070 force 00:00:00.2361009
          forcing 36500:00:00.1830000
          forcing 36500:00:00.3250000
          tbRender 00:00:00.4264496 force 00:00:00.1545505
          tbRender 00:00:00.0025017 force 00:00:00.1570522
          tbRender 00:00:00.3368318 force 00:00:00.4938840

          Every line that says Forcing 365 has a the Draw.Dot on it.

          the tbRender is the amount of time between OnRender calls
          the force is the amount of time after Draw.Dot code has been called and OnRender is called. I don't think this is a good solution. Is there another way to get the OnRender to get called more consistently?

          I can see that it takes as little as 2ms to update the chart. I only need the chart to update consistently within 150 - 200 ms. Ideally I would like it if the time between forcing an update and actually starting the OnRender call is within 50ms, which should be plenty of time.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          597 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