Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Feature suggestion: create State property for RenderTargetChange

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

    Feature suggestion: create State property for RenderTargetChange

    (This request is based on my previous topic, talking about simplification of disposal handling )

    The NinjaTrader Docs ( at https://ninjatrader.com/support/help...getchanged.htm ) suggest using `OnRenderTargetChanged` to handle the creation/disposal of `dx` objects (for example, i talk about brushes). However, it's obviously, that according to the docs, we have to code the disposal handling code in two places (inside OnStateChange and OnRenderTargetChanged).
    Which makes our work complicated (everytime we create a brush or variable, we have to add handling code for their disposal in two areas)

    So, my suggestion

    It would be nice, that like "State" property of NinjaScript, there was State property for RenderTargetState. So, we could easily make such code:

    Code:
    public override void OnRenderTargetChange()
    {
        if (RenderTartgetState == RenderTargetState.Initialize)    // the first trigger of RenderTarget, probably like when "DataLoaded" happens only once
        {
            myDx=  brush.ToDxBrush(RenderTarget);
            .... etc
        }
        else if (RenderTartgetState == RenderTargetState.Default)    // the default state when happens on each event, like clicking on chart or etc..
        {
            myDx=  brush.ToDxBrush(RenderTarget);
            .... etc
        }
        else if (RenderTartgetState == RenderTargetState.Dismissed)    // the only last state when chart/indicator is removed, this should trigger only once, like State.Terminate happens
        {
            if( myDx != null)
            {
                 myDx.Dispose()
                 ... etc
            }
        }
    
    }


    So, this feature will simplify our work with RenderTarget. no need to hook something in "OnStateChange" any longer.
    I also see, that this update wont conflict anything with existing. Just create a new property named "RenderTargetState" and assign the value to it, and then we will do the rest. No drawbacks i see.
    Last edited by ttodua; 03-01-2019, 08:55 AM.

    #2
    Hello TazoTodua,

    Thanks for your post.

    You have a few different threads open on this topic. So we can assist you best, we will ask that correspondence is continued with the technician you are working with for that particular topic. This helps us to ensure that multiple technicians are not working on the same question and helps us to ensure faster response time.

    The help guide documentation you are referencing did not receive an update which we will be corrected to reflect that OnStateChange should not be used for SharpDX resource disposal. All that is necessary would be to use OnRenderTargetChange if you wish to reuse resources throughout multiple render passes. At the end of the script's life, OnRenderTargetChanged will be called and RenderTarget will be null. Your SharpDX resources will then be disposed without being recreated.

    I have created a demonstration video and responded to your thread posted here. Please review my demonstration and response and let me know if you have any questions.

    I look forward to being of any further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim thanks again. sorry for opening multiple threads, just one was different slightly from another. At this moment, as you see, this topic didnt relate to "dispose" problem just. It's a generic feature suggestion to have RenderTargetState impelemnted in NT. however, thanks again ! If you see any point in having `RenderTargetState` would be nice in NT, then submit feature request. if you know that this suggestion doesnt have any affect, then ok, ignore.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bmartz, 03-12-2024, 06:12 AM
      4 responses
      31 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by Aviram Y, Today, 05:29 AM
      4 responses
      12 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by cls71, Today, 04:45 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X