Thread Cleanup and the Paintable Canvas

I wrote a rather lengthy initialization script, called from my Client Startup event. I pushed the bulk of the work onto a background thread with invokeAsynchronous, and updated a splash screen with invokeLater. Once I was certain that all of my necessary initialization had finished, I opened my annunciator window, and closed my splash screen.

The annunciator window contains a large, paintable canvas that previously drew icons to represent physical stations. It had been working quite well for months. Unfortunately, reorganizing my code seems to have broken the repaint event, even though I haven’t altered it. It takes a few extra seconds to draw some text and lines, then it draws a single station, which it happily updates. It will not draw the other stations.

Could opening those various background threads have harmed the performance of the paintable canvas? According to my traces, all of the tasks that I put on the background threads have finished. Is there some sort of final cleanup I need to do to destroy those threads?

No, there’s not anything you need to do to clean up the threads. Once your method completes, the thread started by invoke asynchronous dies.

It must be something else going on inside the painting code. I’d try adding print statements that compare the time between various parts to try and narrow down on what inside the painting code is taking a long time.

Also realize that while the paint event is running, you shouldn’t see anything updating on the screen. What I mean is, you should only see something visually happening after all the painting code has finished running. Is this consistent with what you’re observing?

I found the culprit…it was a stupid coding error…I lost an indent. Thank you.

Glad you found it. Darn those pesky indents!

Another case for improving the script editor so that it shows what code is in a block and what isn’t… I’m just saying! :wink: