• 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

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.

      https://github.com/castleproject-deprecated/castlezmq

      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.
                https://docs.microsoft.com/en-us/dot...ramework-4.7.2
                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 Abilene, Today, 01:27 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post Abilene
                        by Abilene
                         
                        Started by simjs, Yesterday, 08:11 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post simjs
                        by simjs
                         
                        Started by mrlucky1x, Yesterday, 06:01 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post mrlucky1x  
                        Started by dedouglas, Yesterday, 03:17 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by Jugado, Yesterday, 02:22 PM
                        2 responses
                        30 views
                        0 likes
                        Last Post Jugado
                        by Jugado
                         
                        Working...
                        X