Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Windows form timer in State.Dataloaded

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

    Windows form timer in State.Dataloaded

    Hi,

    I was starting a timer with a code sample per below in State.Configure. It worked fine. I noticed some of the references examples (for example TriggerCustomEvent) show a timer being started/configured in State.DataLoaded instead. This also made a little more sense for my purpose, so I did the same. Same code. Just moved it to State.Dataloaded. The issue is that, although that code runs and the print verifies the timer was enabled, the timer never runs. If I move the same code block back up to State.Configure, it works fine again.

    Curious as to what the reason for this is?

    Code sample
    Code:
    // Adds the event and the event handler for the meth od that will
    // process the timer event to the timer.
    
    myTimer.Tick += new EventHandl er(TimerEventProcessor);
    // Sets the timer interval to X milliseconds.
    myTimer.Interval = 500; // ms
    myTimer.Enabled = true;
    //myTimer.Start();
    PPrint("BA Timer started with " + myTimer.Interval.ToString() +"ms");

    #2
    Hello pjsmith,

    The timer you are using should be replaced with System.Timers.Timer.
    The windows forms timer would no longer be used as NT8 now uses WPF, the WPF timers would be more appropriate to be used. Could you try the sample from the help guide in regard to the timers type and how its configured and see if you still have problems?



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi - Good point, and that does, in fact, work fine moved into DataLoaded. Thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      26 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      191 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,230 views
      0 likes
      Last Post xiinteractive  
      Working...
      X