Hey Glenn! Thank you so much for the answer. I feel that whatever environment provided to the plugin should be in a separate thread, but it seems it's in the same thread which is running the UI and that's why this problem occurs. I solved it using an unusual approach. The XPlane detects key shortcuts, and the plugin can be designed to detect key shortcuts. I made a simple python server which sends keystrokes to the XPlane, whenever the delay I want is completed. The plugin sends an int to python server over local socket and python waits for the delay to complete and then it sends the key shortcut after the delay is finished. In that way, the python code is acting as a callback to XPlane but in a weird way. But that works. I hope someone finds it useful. If someone has a better way, please let me know. Thank you.