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

What can cause a hang during compile of an addon?

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

    What can cause a hang during compile of an addon?

    my addon compiles usually.. and it does access an external dll.

    However, I added one call to the dll.. one line.. and every time I try to compile this it hangs the nt8 platform and makes a weird, "failed" sound. But the platform is hung. Furthermore it will hang every time afterwards when trying to run NT8... so I have to restore an older version of the documents NinjaTrader folder to get back to a pre-compiled state that doesn't have this problematic line.

    Is there a way I can compile this outside of ninjatrader? (I don't have visual studio, so I need to know another way)

    What is happening here? is the addon actually finishing compile and starting to run and getting hung there? That still wouldn't explain the compile failed sound though...

    it's an actual addon - not indicator or strategy or anything but addon

    #2
    Hello NinjaCustomer,

    It sounds like there is an issue with something in the external dll.

    Is the external dll a NinjaScript indicator or addon?

    If so, I'd like to test it on my end.


    If not, this would be outside of what is supported by NinjaTrader Support.

    Though that said, was this external dll created to target .NET 4.5?

    Does the external dll require other dlls as dependencies?

    Are you able to successfully use this external dll in other .NET 4.5 applications that are not NinjaTrader?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I can use this dll successfully in general even in ninjatrader.. I have been using it for some time. I think it is more about where I'm calling it that's the problem I guess. The part that confuses me is why it hangs after unsuccessfully compiling (but I don't see an error message, I mean, it should successfully compile but it makes a failure sound and hangs right after that)

      it is not a ninjascript dll .. the external dll is a ZeroMQ dll. ZeroMQ is a way to communicate over protocols over ports like tcp and such. I'm not really sure if it requires the .net framework but I haven't had to install anything.

      Modern and robust .net binding for 0mq (zmq). Contribute to castleproject-deprecated/castlezmq development by creating an account on GitHub.


      The thing is, I can use it in my ninjatrader addon and have been for months - it is just what I'm currently trying to do with it causes this problem. So I'm wondering if it is more due to where it is being run in the code than what it is trying to do.

      From what I've described, do you think it compiled completely? and that NT8 would then start running it as an addon? note: the older version of my addon was running before trying to compile the code with the problematic line.

      How I'm running the code is by using a ThreadPoolQueueUserWorkItem() (i.e. running a separate thread) from within OnStateChange() - (if (State == State.SetDefaults) )

      is this a problematic area to start running code in a separate thread?


      Comment


        #4
        Hello NinjaCustomer,

        The OnWindowCreated() is actually run for all AddOn scripts after a compile. If its a run-time error it could be from that.

        A way to test would be to put that line of code in a condition that is never true, like if (false) { /* line here */ }.

        That will prevent that line of code from being run in run-time. Then you can check to see if its an issue with compiling or if its a run-time error causing the hang.

        You mention threading. Maybe you are running into a thread deadlock from accessing a thread without a Dispatcher.InvokeAsync()?

        Custom threading can be pretty complicated and far outside of what is supported by NinjaTrader. However, this thread will remain open for any community members that would like to assist.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          so are you saying that Dispatcher.InvokeAsync() has some safety measures in place compared to starting threads other way? I'm not really a C# person but Java

          Comment


            #6
            Hello NinjaCustomer,

            InvokeAsync() is how you access an object in another thread.

            As an analogy if you were on a bus and you wanted to get an item from someone on another bus through the window, you would need the buses to go the same speed for a moment so that information or objects can be passed. Then the buses would resume their normal separate speeds once the invoke is complete.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              how can I call InvokeAsync() ( I mean access a Dispatcher ) from
              OnStateChange() ?

              Comment


                #8
                Hello NinjaCustomer,

                It depends on what thread you want to invoke into. But the call is Dispatcher.InvokeAsync().

                Below is a link to an example that uses Dispatcher.InvokeAsync().
                http://ninjatrader.com/support/forum...059#post477059

                Also, below is a public link to the Microsoft documentation.

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  while I've solved my previous problem by moving the thread starting code to OnWindowCreate from set defaults, now I have a new problem...

                  after a while of running my code, NinjaTrader makes a "failure sound" and then crashes (closes completely).

                  I thought maybe this meant an unhandled exception but I surrounded my code with a try catch and still this occurs.

                  So would you have any thoughts as to what could cause this? excessive memory usage? (don't think that's happening though).. something else?

                  I'm not using a dispatcher since at least running on the window dispatcher, it can freeze the UI.. starting a separate thread with ThreadPoolQueueUserWorkItem() does not cause any UI freezing.

                  Comment


                    #10
                    Hello NinjaCustomer,

                    Crashes can be caused by a lot of different things. Especially when using unsupported code.

                    OnWindowCreate() runs when NinjaTrader starts and the Control Center is created and also runs anytime a compile is done for any changes to the menus of the Control Center.

                    My tip is making sure everything you are doing on another thread is making sense and isn't accessing any NinjaTrader threads without invoking.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I'm sure it's not accessing anything it is not supposed to, it doesn't access any ninjatrader objects - is there any place where an exception causing a crash would be logged?

                      Comment


                        #12
                        Hello NinjaCustomer,

                        If the crash occurs on a NinjaTrader thread from a NinjaTrader method, there is a possibility it may be written in the trace.
                        Documents\NinjaTrader 8\trace.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Barry Milan, Today, 10:35 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by WeyldFalcon, 12-10-2020, 06:48 PM
                        14 responses
                        1,428 views
                        0 likes
                        Last Post Handclap0241  
                        Started by DJ888, Yesterday, 06:09 PM
                        2 responses
                        9 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        3 responses
                        40 views
                        0 likes
                        Last Post jeronymite  
                        Started by bill2023, Today, 08:51 AM
                        2 responses
                        16 views
                        0 likes
                        Last Post bill2023  
                        Working...
                        X