Show progress of code executed on form submit
Surely you need to implement Batch API to achieve what you need, and keep the user notified for what's happening in the background.

Very similar question that will help you more. Read it carefully.

These modules will help you:


Progerss This is an attempt to implement a generic framework for keeping track of any progress 
Background progress takes over the existing Batch API and runs batch jobs in a background process