Multithreading with ESAPI

Aug 25, 2015 at 6:11 PM
When writing a plug-in script for Eclipse, ESAPI objects must be accessed from the main thread (i.e., the thread that executes the Script.Execute method). This thread is also our GUI thread. When performing long-running calculations using ESAPI objects, the GUI freezes because it's running on the same thread as the calculations. What's a clean way to solve this problem? In other words, how do you make the GUI responsive, and even show a progress bar, while performing calculations involving ESAPI objects?

One possible solution I've thought about, but not yet implemented, is to create a separate GUI thread (with its own dispatcher) to display the main window, and use the original thread to perform calculations (treating it as a background thread). This implementation may involve using a concurrent queue to communicate between threads.

I've also posted this discussion topic on the OncoPeer Developer website.
Apr 25, 2016 at 4:16 PM
I implemented the solution I suggested here, and I wrote a blog post about it: Create ESAPI Scripts That Don't Freeze the UI.