title: iOS - Process data without freezing the UI
body: <p>I need to do the following tasks:</p>
  
  <p>1) Read some data from sqlite database</p>
  
  <p>2) Process the data</p>
  
  <p>3) With the processed data generate some charts</p>
  
  <p>If I have a user who enters many data in the application, one day this analisys can become slow and freeze the UI.</p>
  
  <p>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?</p>
  
  <p>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?</p>
  
  <p>For example:</p>
  
  <p>Task 1: Read the data from sqlite in a thread with a flag to stop the process if needed.</p>
  
  <p>Task 2: Process the data in a thread with a flag to stop the process if needed.</p>
  
  <p>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?</p>
  
  <p>Am I thinking the right way or I could improve on something?</p>