I'm creating a plug-in for an开发者_如何学Go application and, to request data to the user, I need to create a thread since the GUI should stay responsive and the application may not call any of my functions for a long time.
The problem is that most GUI libraries I know (wxWidgets, Qt) don't seem to support creating a GUI from another thread. Sometimes there are tricks to get it done, but it's not portable nor guaranteed.
I'm looking from a GUI library that officially supports launching GUIs from another thread. The only requeriments for the project are portability to Windows, Linux and Mac and exposing a C interface. Bonus points for lightweightness.
Nearly all GUI libraries work by relying on the underlying operating system's API. When you go "cross platform" in your requirements, this gets even more strict, as you now have to rely on support of 3 separate platforms.
As such, I suspect you'll find that every (reasonable) GUI library will have thread affinity.
That being said, nearly every library supports creating work from other threads, and having background threads do the "processing" while the UI sits, nice and responsive, on the main UI thread. I would suggest reworking your design to allow your operations to function on background threads, not your UI.
精彩评论