Dialog Box Busy

My dialog application uploads a file to a microprocessor system through an RS-232 port.
Clicking a button starts uploading.
While running the application is not accepting any button clicks.
A progress bar is following the upload procedure.

The problem is that very often the progress bar freezes and the cursor turns to a sand clock. The process always goes to the end and eventually the progress bar gets completed but meanwhile everything stays frozen.
The same happens if the user tries to move the dialog while running or change the focus out of the dialog.