I have code in various places that’s running on background threads and needs to pass data back up to the UI. I know you can use the MessageManagerLock to ensure the calling thread has exclusive access to the message loop, but I’ve run into situations where using that has caused crashes. What has worked pretty well – on OS X – has been to wrap whatever callbacks I need performed in an objective c object and use the Cocoa method performSelectorOnMainThread to run the callback like so:
[objcRunnable performSelectorOnMainThread:@selector(run)
withObject:nil
waitUntilDone:NO];
I was wondering if anyone knows whether there’s an equivalent for this on Windows.