Thanks, mats. I'm going to try this.
The problem with the interlocked functions was that I couldn't find one that allowed me to simple read the value as an atomic operation.
I question this one, since I don't want to do a message loop inside the event handler.
And another problem right now is that there are GUI calls inside thread B, so it's critical that the message loop is running at all times.
And running a message loop inside the event handler is an old way of doing things IMO. It can be error prone.
But one way might be a MFC thread that does a message pump. But again, I want to avoid complications and rewrite the threading code.