I have been able to avoid the error by using Await Task.Delay. My code is now:
StartTime = DateTime.Now
Button3.IsEnabled = False
Button3.Content = StartTime.TimeOfDay.ToString.Split(".")(0)
Await Task.Delay(60000).ConfigureAwait(True)
Before, the last line was:
Task.Delay(60000).Wait()
It seems that with Task.Delay the previous content is not captured and execution fails (same happens if I use Await Task.Delay(60000).ConfigureAwait(False))
I do need the long delay because I have to wait for an external device to boot up
What I do not yet understand is why I get no error in the other program that has the same code and uses Task.Delay.
Anyway. I will use Await Task.Delay from now on, which seems to have the additional benefit of allowing me to interact with the UI while the task is delayed.
I need to study and understand better the differences and implications of using the two alternatives to insert a delay in the execution of code.