Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is Print() involed with threading?

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

    Is Print() involed with threading?

    I have the following code:
    Code:
                if (message.Length != 0) s += "\n" + leadingTabs + message;
                Print(s);
    "s" is a local string variable. The second line (Print(s) just got a threading exception:

    ThreadAbortException was unhandled
    An unhandled exception of type 'System.Threading.ThreadAbortException' occurred in WindowsBase.dll
    This is the first time I have seen this exception, so I doubt I can supply a test case. It may be happening now because I am using the VS debugger and that alters timing.

    Am I doing anything wrong? Do I need to take any steps to ensure that Print() statements are thread safe?

    --EV

    #2
    As far as I have seen, this should not be an issue. If it is not reproducible outside of the VS Debugging scenario, then I would say that you are probably correct in identifying this as the cause. If you can reproduce this without VS Debugging attached, please let me know.

    As a test, you might try nesting the Print statement inside Owner.Dispatcher.Invoke to ensure it's called on the main UI thread of the calling object, but as I noted, this should not be a requirement under normal circumstances.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      I have now seen it repeatedly in VS, but only when I put a breakpoint nearby. Otherwise no problem running the code in VS. It sure looks as if either VS has a bug, or else VS alters something enough to tickle an NT bug. I've never seen the problem outside of VS, and then only when I have a nearby breakpoint.

      --EV

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by guillembm, Yesterday, 11:25 AM
      2 responses
      9 views
      0 likes
      Last Post guillembm  
      Started by junkone, 04-21-2024, 07:17 AM
      9 responses
      68 views
      0 likes
      Last Post jeronymite  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      4 responses
      18 views
      0 likes
      Last Post trilliantrader  
      Started by mgco4you, Yesterday, 09:46 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by wzgy0920, Yesterday, 09:53 PM
      0 responses
      10 views
      0 likes
      Last Post wzgy0920  
      Working...
      X