Setting the main event loop needs to be protected