I want too set progress bar in my Ui which increases as my code is being processed.

I am doing heavy calculation in my code to calculate the X and Y cordinates which freezes my ui for few second and i want to use progress bar to be filled in that duration any idea