In a function running in a non-UI application:
void MyFunctionThatIsACallBack() {}
What options do I have to force the code in MyFunction() so that it runs in the main thread?
The function is a call back from another section of code that may or may not be in the main tread.
This isn’t as simple a question as it seems. The main thread would need to be running in a loop, reading work items off of a queue and processing them. You can’t just usurp a thread’s context and make it do some arbitrary other thing.
My suspicion is that there is some deeper threading issue that you are seeing, and this probably isn’t the way to solve it.