The basic problem is that you have a long running function and new functions are created while it runs. Due to performance reasons a function can only call older functions essentially. To work around this you need to use Base.invokelatest. see e.g. this SO thread for more details
2 Likes