Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
The calling thread cannot access this object because a different thread owns it.
Collapse
X
-
Brett,Originally posted by NinjaTrader_Brett View PostWent though this with Development and Product Management team was just educated that yes we should be Freezing brushes due to the multi-threaded nature of NinjaTrader.
This has impact with DrawingTools, Setting Plots, Setting Lines, and OnRender method.
I will start adding documentation this week to make this more clear, thanks guys for running through this.
I am sure you guys are on this, but just wanted to post PENs should be frozen as well. They are based upon the Freezable class as well.
Leave a comment:
-
Ah! Excuse my stupidity, please.Originally posted by NinjaTrader_Brett View PostNever said compilation
( I think that was incorrectly pulled from another poster). Will just be a runtime exception caught and logged just like any other exception occurring in a NS object so we are consistent with how we handle.
Leave a comment:
-
Never said compilation
( I think that was incorrectly pulled from another poster). Will just be a runtime exception caught and logged just like any other exception occurring in a NS object so we are consistent with how we handle.
Leave a comment:
-
Brett, your statement is a bit ambiguous. There is a difference between the various events each potentially running on a different thread each, and each of them running on multiple threads.Originally posted by NinjaTrader_Brett View PostProblem is not one thread is used in the majority of situations.
OnBarUpdate, OnStateChanged, OnMarketData, OnMarketDepth is all multi-threaded. Sure the render call is the only one thats not but its better to freeze then have the majority of clients run into intermittent issues is current thinking.
In the former situation, scope considerations would mean that a brush defined in one event would not be available outside it anyway, and if each event is running on a single thread (albeit a different thread from the other events), then, again, Freeze()ing may need to be optional. Of course, if the latter is the case, then you are absolutely correct.
Regardless, it might be useful to have a warning if any brush is not Freeze()d. I am just not sure that an enforced compilation failure is the correct solution. Any brush declared in class scope, on the other hand, should probably be mandatorily Freeze()d, and so result in an enforced compilation failure.
Leave a comment:
-
Brett,Originally posted by NinjaTrader_Brett View PostProblem is not one thread is used in the majority of situations.
OnBarUpdate, OnStateChanged, OnMarketData, OnMarketDepth is all multi-threaded. Sure the render call is the only one thats not but its better to freeze then have the majority of clients run into intermittent issues is current thinking.
I agree, you need something, I had been chasing this bug for about 8 days! A compiler failure or atleast a warning or log error, something is required to notify the coder of a Multi-Tasking error.
After I thought I got them all, I found another Brush used deeper in the code, a compile warning or failure would have helped.
Leave a comment:
-
Plus if your in OnRendner you've committed to handling things yourself anyways. Could always handle yourself instead. (Don't use Draw. methods etc.)
Leave a comment:
-
Problem is not one thread is used in the majority of situations.
OnBarUpdate, OnStateChanged, OnMarketData, OnMarketDepth is all multi-threaded. Sure the render call is the only one thats not but its better to freeze then have the majority of clients run into intermittent issues is current thinking.
Leave a comment:
-
Hm. That may be overkill. It is only necessary to freeze brushes that may possibly be accessed across threads. If the brush is confined to one thread, such as being defined in OnRender() for example, there may be no need to freeze it.Originally posted by NinjaTrader_Brett View PostFurthermore, I will ask development to terminate the NS and log an error explaining to you that you needed to freeze the brush if a non-freezed brush is passed in. Which should help for future cases as well.
This becomes especially important if we intend to change the color or any other properties of the brush, (as for example, drawing multiple lines of text that have different colors or backgrounds). Granted that we can always Clone() the brush and so in a roundabout fashion change the brush properties, it may sometimes simply be preferable to modify the brush directly.
Just my $0.02.
Leave a comment:
-
Furthermore, I will ask development to terminate the NS and log an error explaining to you that you needed to freeze the brush if a non-freezed brush is passed in. Which should help for future cases as well.
Leave a comment:
-
Went though this with Development and Product Management team was just educated that yes we should be Freezing brushes due to the multi-threaded nature of NinjaTrader.
This has impact with DrawingTools, Setting Plots, Setting Lines, and OnRender method.
I will start adding documentation this week to make this more clear, thanks guys for running through this.
Leave a comment:
-
Grrrr...
Okay, I am not getting the same error, getting a different one intermittently... So not quite out of the woods yet:
Code:2015-06-03 16:26:05:034 ERROR: Failed to call 'Add' method: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock.
Leave a comment:
-
Wow!Originally posted by koganam View PostTry freezing the new SolidBrush() first.
This is a biggie... I tried this and think it may have fixed a lot of other intermittent issues. This is important to discuss in the NinjaScript reference!
"Freezing" the brushes seems to have cleaned up and closed this issue.
Leave a comment:
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by kinfxhk, 07-13-2026, 10:18 AM
|
0 responses
30 views
0 likes
|
Last Post
by kinfxhk
07-13-2026, 10:18 AM
|
||
|
Started by kinfxhk, 07-13-2026, 09:50 AM
|
0 responses
24 views
0 likes
|
Last Post
by kinfxhk
07-13-2026, 09:50 AM
|
||
|
Started by kinfxhk, 07-13-2026, 07:21 AM
|
0 responses
30 views
0 likes
|
Last Post
by kinfxhk
07-13-2026, 07:21 AM
|
||
|
Started by kinfxhk, 07-11-2026, 02:11 AM
|
0 responses
27 views
0 likes
|
Last Post
by kinfxhk
07-11-2026, 02:11 AM
|
||
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
141 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|


Leave a comment: