Hopefully this might help others not run into the same issue of executing outside of a user interaction event loop.