I have an application which does many lines of calculation. While calculation is done, I need to show a progress bar with a cancel button.
But the issue is that, while processing, the whole ui gets freezed and non-responsive. Cancelling button doesn't reach to the method where the event is being listened.
Breaking the code in multiple frames of not more than 100ms, updates the text on progress bar but ui is still not responsive. And moreover the overall time for processing increases significantly. Can anybody suggest some solution to this?
What happens is that your calculation is hogging the CPU.
This is because of what we call the Flash Player elastic racetrack:
Your calculation takes so many CPU cycles that there is none left for rendering and mouse/keyboard interactions. In fact, anything that you do in Flex should last less than the duration of a frame. Your calculation exceeds that frame duration, hence the slowdown.
There are solutions.
Using Pixel Bender with Flash Builder 4 as a number crunching engine