Explanation of need for Multi Threading GUI programming

后端 未结 3 2105
清歌不尽
清歌不尽 2021-02-08 15:44

I\'m looking for a good explanation of the need to use multi-threading in graphical applications. In the examples below Python is used but the question is not python specific it

3条回答
  •  梦如初夏
    2021-02-08 16:24

    The main reason is, that GUI toolkit process all events (mouse movement, button click, keyboard input, system events, etc) in the mainloop, which is not part of the code you write for you GUI application.

    This main loop call all the event handlers and other functions you provide. Now, if one of those functions take too long (e.g. > 100ms), then there will be a very noticeable effect on UI responsiveness, as the main loop will not be able to process more events.

    This topic should be discussed in details in the "advanced concepts" section of any book on GUI programming, regardless of programming language of toolkit used.

提交回复
热议问题