Unable to enter code into another stream. Even the operating system cannot do this.
Control.BeginInvoke works by queuing a delegate link and then using PostMessage to send the user message to the message queue of the UI thread. The Application.Run message loop searches for this message, and when it finds it, it issues the delegate from the queue and executes it.
The fact is that there is no other way to do what you need if your main stream is not encoded to look for some signal (or message) from another stream.
Added
You stated that this is a WinForm application, but you do not have a control to use BeginInvoke with.
Edit: I suggested lazy loading without thinking about it. The control may end up creating in the wrong thread .
Pre-create the control before Application.Run , which lives throughout the life of the application. You can use this for BeginInvoke from.
Edit # 3
So, I'm trying to do this to make sure that it works, and of course not. You cannot just create a common control, it must have an HWND handle. Simple fix: create it like this:
invokerControl = new Control(); invokerControl.CreateControl();
This will allow you to BeginInvoke from it, even if there are no open Form objects to call from.
source share