Thanks.
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!
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
NinjaTrader
AddOn vs NinjaTrader Exit/Shutdown
Collapse
X
-
AddOn vs NinjaTrader Exit/Shutdown
When Exiting (shutting down) NinjaTrader, how should one handle disposing of AddOn variables declared in AddOnBase that should, in normal usage, be Disposed, or at least set to null? For example, HttpClient or similar. Is there any need (or good reason) to do this when Exiting? If so, where is that done?
Thanks.Tags: None
-
Hello jeronymite,
Thank you for your reply.
Yes, is important to unsubscribe from event handlers and dispose of unused resources when they are no longer needed. The OnWindowDestroyed() method can be used to clean up any resources when closing out of NinjaTrader.
I'm attaching this example AddOnShell that demonstrates cleaning up a click handler and removing the menu item for the window from the Control Center when the Control Center is closed.
Please let us know if we may be of further assistance to you.
Attached FilesKate W.NinjaTrader Customer Service
-
Thanks, Kate.
This is good to know. Nonetheless, OnWindowDestroyed is called when a NinjaScript object is compiled as, apparently, that causes all existing windows to be destroyed and recreated. Is there a way to determine unequivocally that NinjaTrader is shutting down and that's why the windows are destroyed?
Thanks.
Comment
-
Hello jeronymite,
Thank you for your reply.
If the ControlCenter window is updating OnWindowDestroyed() then likely NinjaTrader is shutting down, since closing that window isn't possible without exiting the platform.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Thanks again, Kate.
Actually, all windows are destroyed and recreated when an AddOn is compiled. This can easily be seen if one prints a diagnostic message in both OnWindowDestroyed and OnWindowCreated identifying the window being destroyed or created. The ControlCenter is always one of those windows. So, without further explicit and definitive information, it is not possible, from within OnWindowDestroyed alone, to know if NinjaTrader is shutting down or if it is a recompile.
Grateful for your further investigation to determine how one might unequivocally know that NinjaTrader is shutting down as opposed to a recompile being done.
Thanks.
Comment
-
Hello jeronymite,
Thank you for your reply.
There would not be an alternate method to determine whether NinjaTrader is shutting down. We do have an existing feature request to add a property to OnWindowDestroyed() that tells if the addon window is being closed by the user or by NinjaTrader closing the workspace / shutting down. I have added a vote on your behalf to this request, which is being tracked using the number SFT-4752.
As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.
Release Notes — https://ninjatrader.com/support/help...ease_notes.htm
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by GLFX005, Today, 03:23 AM
|
0 responses
1 view
0 likes
|
Last Post
by GLFX005
Today, 03:23 AM
|
||
Started by XXtrader, Yesterday, 11:30 PM
|
2 responses
11 views
0 likes
|
Last Post
by XXtrader
Today, 03:07 AM
|
||
Started by Waxavi, Today, 02:10 AM
|
0 responses
6 views
0 likes
|
Last Post
by Waxavi
Today, 02:10 AM
|
||
Started by TradeForge, Today, 02:09 AM
|
0 responses
12 views
0 likes
|
Last Post
by TradeForge
Today, 02:09 AM
|
||
Started by Waxavi, Today, 02:00 AM
|
0 responses
2 views
0 likes
|
Last Post
by Waxavi
Today, 02:00 AM
|
Comment