The general strategy for event-based programs that must do long calculations is one of the following:
- break the calculations into small chunks that take no more than a few 10's of milliseconds, then schedule them to run one after the other when the event loop is idle. Remember: the event loop is just a loop, so if your long running calculation is just a huge loop of tight and fast code let the event loop be your loop.
- put the long running calculation in a separate thread and have that thread communicate its results back to the main thread in a thread-safe manner
- put the long running calculation in a separate process and have that process send updates back to your main process
The first method is ideal if you can manage it. My personal preference then goes to the third method. IMO threads should be avoided if at all possible, unless you fully grok threaded programming (and even then I still usually recommend a separate process).