How to wait AddToViewport complete?

My solution is: create a new thread