Custom Function - Wait for code to finish before loading

Custom Function - Wait for code to finish before loading

We are currently using a custom function which, in part, pulls information from a Contact Record and adds it to a custom field in a Sales Order after formatting it. The custom function is triggered by a workflow rule when a sales order is created or edited. We are finding that when we edit this custom field in the Sales Order to trigger a value update from the contact record it doesn't finish updating the record until a few seconds after the Save button has been clicked and the sales order needs to be refreshed again by the user to display the new values.

Is there a way to delay the loading of the Sales Order screen until the custom function is completed? A way to introduce a 'Please wait while we update the Sales Order.' message for a few seconds and then refresh the screen? Or is there some other way to ensure fields are updated before users attempt to reference them in the Sales Order?

Thank you.