• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 TazoTodua; 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 rickyblah12, Yesterday, 08:17 PM
      0 responses
      6 views
      0 likes
      Last Post rickyblah12  
      Started by mrlucky1x, Yesterday, 08:07 PM
      0 responses
      2 views
      0 likes
      Last Post mrlucky1x  
      Started by uday12, Yesterday, 07:21 PM
      0 responses
      4 views
      0 likes
      Last Post uday12
      by uday12
       
      Started by voltlon, Yesterday, 05:18 PM
      0 responses
      8 views
      0 likes
      Last Post voltlon
      by voltlon
       
      Started by Bobisam, Yesterday, 04:57 PM
      0 responses
      9 views
      0 likes
      Last Post Bobisam
      by Bobisam
       
      Working...
      X