TCriticalSection" added to main timer loop to stop it being called again while executing