How to properly access query-results created in background thread?

前端 未结 2 1010
不知归路
不知归路 2021-02-04 17:57

I want to execute a database query in a background thread. The OmniThread library will help me with all the thread stuff, but there is one thing I don\'t understand so far:

2条回答
  •  忘掉有多难
    2021-02-04 18:44

    The best way is probably to not use db-aware components in the GUI. Threads should communicate with the database and store information in business objects, which can be then sent to the main thread (which will display them).

    Multithreading is hard, not only from the implementation perspective but also from the view of the application design. It's usually best if you think of the background threads as a separate layer with well-defined inputs and outputs.

提交回复
热议问题