When calling while(IoC.Get().IsSimulationRunning) the program freezes completely, but if you add the VcMessageBox code.Show(“”) and further code execution is successful(the program does not hang), what could be the reason?
VC is single-threaded. You can’t just run such a while loop as it will not let any other code to run. Your add-on needs to be implemented such that it reacts to events from the API and UI, never blocking the main thread.
Only special case is the OnRun method in Python scripts, because that is executed using co-operative multitasking with some safeguards.
Ok, Thanks! Then how can I ensure that during a running simulation, for example, coordinates are recorded every 3 seconds? It possible?
If you want to run some logic at specific times of simulation time (such as regular interval), use ISimulation.ScheduleCallback(...)
method.