I take from your question that changing myLongLastingFunction not possible to give you periodic updates about progress, and this ability does not currently exist in this function.
For these scenarios, when the duration of the task cannot be determined, a progress bar with the dependency property IsIndeterminate="True" is the accepted way of providing this information to the user. This enlivens the continuous scroll of the progress bar.
Xaml
<ProgressBar Margin="10" IsIndeterminate="True" />
I personally prefer animated moving points, as shown on Windows Phone. An example is implemented here .
If this is not what you need, the best method is to estimate the total time and split that time into DispatchTimer to give a periodic event to increase the progress bar. This, obviously, has two problems, either to the finish line before reaching 100% (not bad), or reaching 100%, and gets stuck there, since the actual time significantly exceeds the estimate. The second unwanted effect will make the application look inactive again.
source share