Keeping GUIs responsive during long-running tasks

前端 未结 9 2097
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 22:28

Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming.

Here\'s a good discussion of h

9条回答
  •  隐瞒了意图╮
    2020-12-14 23:20

    For some types of operations, using separate processes makes a lot of sense. Back in the day, spawning a process incurred a lot of overhead. With modern hardware this overhead is hardly even a blip on the screen. This is especially true if you're spawning a long running process.

    One (arguable) advantage is that it's a simpler conceptual model than threads that might lead to more maintainable code. It can also make your code easier to test, as you can write test scripts that exercise these external processes without having to involve the GUI. Some might even argue that is the primary advantage.

    In the case of some code I once worked on, switching from threads to separate processes led to a net reduction of over 5000 lines of code while at the same time making the GUI more responsive, the code easier to maintain and test, all while improving the total overall performance.

提交回复
热议问题