RobotStudio event

How to continuosly read robot joint configuration with PC SDK?

depa91 Wien
I'm working on a project that requires creating a digital-twin between a robot controller and an Unity3D environment.

I'm using Robot Studio as an emulation environment with a virtual IRB 2600 robot.
When the virtual IRB 2600 moves in Robot Studio, another virtual IRB 2600 should move accordingly in the Unity3d environment.

My idea is to read the joint configuration (using PC SDK) of the IRB 2600 robot instantiated in Robot Studio and then send it to Unity3D over a socket connection.

According to the joint configuration can be accessed using the GetPosition() method of the MotionSystem class.

However, I'm not sure how to continuously read the joint configuration.
Should I use a simple "infinite" while loop or is it possible to be notified when the joint configuration has changed (e.g., with an event)?

Thank you