My app is using some instances of the task class to do work and update the UI. Generally this is working OK but two threads in particular are giving me a problem - they both get a threadaccessingUI exception when they terminate. Unfortunately the traceback doesn’t appear to give much useful info, but looking through old posts here I see a reference to a page that talks about a command-line program called threadedui that I could run to get more info.
But the link to where it is gets a 404 - so where is threadedui these days?
Tim, I had similar issues, and my first guess would be that your threads are holding onto the last reference to a UI element (such as a window) that has been closed. So although you may think you closed the window in a non-threaded construct, the destructor isn’t actually firing until the thread itself is destroyed. You might try using WeakReferences to the UI elements instead.
@Beatrix Willius I’m still using 2016r1 as there was some threads issue with later versions. Whether that’s been fixed I don’t know.
@Michael Diehr Yes, that’s exactly it. I had another look at the trace and a quick test showed that if I left the window open until the thread completed, the exception didn’t occur. So now I’m not going to let the user close it until the thread completes.
The window is there so the user can choose a folder. Then the thread needs to get to work (may take an hour or more). Once they’ve chosen the folder, the window’s not needed. So I don’t want to be killing the thread.