WorldAnchorTransferBatch.ImportAsync fails with error

So I’ve successfully transferred an anchor from one Hololens to another but when I try to import it I get this error message:

ImportAsync_Internal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

I’m calling WorldAnchorTransferBatch.ImportAsync from a standard Monobehaviour script. What am I doing wrong?

Make sure that you wait until all of the data is downloaded first and then call your ImportAsync. This error usually happens when Unity is not finished doing something and you tell it to do something else

Apparently I was in a another thread. The solution was to implement a Producer-Consumer pattern Queue on main thread (e.g. gets consumed in Update()).