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 Mindset, Today, 06:46 AM
      0 responses
      11 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, Yesterday, 05:21 PM
      0 responses
      17 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      15 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      82 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      49 views
      0 likes
      Last Post PaulMohn  
      Working...
      X