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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      672 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      577 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X