I have a class created to act as a thread.
In that class, I create an object. This objects has an event which performs a callback to a method created within my thread class.
So then, my main application/GUI thread creates this thread & starts it.
At this point, my main GUI thread sits idle (awaiting keyboard events) & my thread’s execute method sits in an infinite loop (waiting for terminate).
Then, the created object detects something, firing an event, which triggers the call-back to the thread classes method.
The question then is, which thread/process is this method performed in?
My main application thread (& GUI handler)?
Or the thread I started, which created the object that fired the event/callback?
I’m presuming that the main application thread is interrupted. Is this right?
There is no magic here, the event handler simply runs on the same thread as the code that fired the event. Which is invariably troublesome when you want the event handler to update the UI, that isn’t legal to do from any thread other than the one that created the UI objects.
You will have to marshal the call from the worker thread to the UI thread. That’s always supported by whatever class library you use the implement the UI. You didn’t say, it smells like Winforms in which case you use Control::BeginInvoke(). If it is raw Windows then you use PostMessage(). Etcetera.