The original codes

This button is in a simple form as below. The labels in red color are used to display the “waiting” box.

The problem

As in the sample handler, the execution take a long period of 10 seconds – the user will get a “not responding” state of the application. This seems to be not very friendly; a more lovely behaviour would be show a “please wait” box so as 1) to notice the user and 2) to get rid of “not responding” state.

This means we need to “move” the long execution to a background thread/worker and continue to finish the handler method. The background worker when finish will update the “waiting” box to “done”.