iOS - Process data without freezing the UI

Viewed 11858

I need to do the following tasks:

1) Read some data from sqlite database

2) Process the data

3) With the processed data generate some charts

If I have a user who enters many data in the application, one day this analisys can become slow and freeze the UI.

So, what is the correct way to process it allowing the user to interact with the UI, with the option to cancel the operation or exit the screen?

I need to make simple threads for all my tasks and with a cancel event or flag to stop each one? Or there is another way do to it?

For example:

Task 1: Read the data from sqlite in a thread with a flag to stop the process if needed.

Task 2: Process the data in a thread with a flag to stop the process if needed.

Task 3: Deliver the data to a 3rd party component. At this point, its possible to cancel the operation that is running on other component?

Am I thinking the right way or I could improve on something?

2 Answers
Related