I have a Python script that handles aynchronous callbacks from .NET Remoting. These callbacks execute in a dummy (worker) thread. From inside my callback handler, I need to call a function I've defined in my script, but I need the function to execute in the main thread.
The Main thread is a remote client that sends commands to a server. Some of these commands result in asynchronous callbacks.
Basically, I need the equivalent of .NET's Invoke method. Is this possible?
You want to use the Queue class to set up a queue that your dummy threads populate with functions and that your main thread consumes.
Demo:
Prints:
and then blocks forever