久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <small id='gk1IX'></small><noframes id='gk1IX'>

    <i id='gk1IX'><tr id='gk1IX'><dt id='gk1IX'><q id='gk1IX'><span id='gk1IX'><b id='gk1IX'><form id='gk1IX'><ins id='gk1IX'></ins><ul id='gk1IX'></ul><sub id='gk1IX'></sub></form><legend id='gk1IX'></legend><bdo id='gk1IX'><pre id='gk1IX'><center id='gk1IX'></center></pre></bdo></b><th id='gk1IX'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gk1IX'><tfoot id='gk1IX'></tfoot><dl id='gk1IX'><fieldset id='gk1IX'></fieldset></dl></div>

        • <bdo id='gk1IX'></bdo><ul id='gk1IX'></ul>

        <legend id='gk1IX'><style id='gk1IX'><dir id='gk1IX'><q id='gk1IX'></q></dir></style></legend>

        <tfoot id='gk1IX'></tfoot>

        所有任務(wù)的單個工作線程還是多個特定工作人員

        Single worker thread for all tasks or multiple specific workers?(所有任務(wù)的單個工作線程還是多個特定工作人員?)

              <bdo id='eXQQZ'></bdo><ul id='eXQQZ'></ul>
              <i id='eXQQZ'><tr id='eXQQZ'><dt id='eXQQZ'><q id='eXQQZ'><span id='eXQQZ'><b id='eXQQZ'><form id='eXQQZ'><ins id='eXQQZ'></ins><ul id='eXQQZ'></ul><sub id='eXQQZ'></sub></form><legend id='eXQQZ'></legend><bdo id='eXQQZ'><pre id='eXQQZ'><center id='eXQQZ'></center></pre></bdo></b><th id='eXQQZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eXQQZ'><tfoot id='eXQQZ'></tfoot><dl id='eXQQZ'><fieldset id='eXQQZ'></fieldset></dl></div>
              <tfoot id='eXQQZ'></tfoot>

              1. <small id='eXQQZ'></small><noframes id='eXQQZ'>

                    <tbody id='eXQQZ'></tbody>
                  <legend id='eXQQZ'><style id='eXQQZ'><dir id='eXQQZ'><q id='eXQQZ'></q></dir></style></legend>
                • 本文介紹了所有任務(wù)的單個工作線程還是多個特定工作人員?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在使用 PyQt5 創(chuàng)建一個簡單的 GUI 應(yīng)用程序,我從 API 請求一些數(shù)據(jù),然后用于填充 UI 的各種控件.

                  I'm creating a simple GUI application using PyQt5 where I request some data from an API which is then used to populate various controls of the UI.

                  我在 PyQt 中關(guān)注的關(guān)于工作線程的示例似乎都是 QThread 的子類,然后在重寫的 run() 方法中執(zhí)行它們的業(yè)務(wù)邏輯.這工作正常,但我想使用工作人員在不同時間執(zhí)行不同的 API 調(diào)用.

                  The examples I was following about worker threads in PyQt all seem to sub-class QThread and then do their business logic in the overridden run() method. This works fine but I want to execute different API calls at different times using a worker.

                  所以我的問題是:我是否需要為我希望執(zhí)行的每個操作創(chuàng)建一個特定的工作線程,或者是否有一種方法可以讓我可以使用單個線程類在不同的時間執(zhí)行不同的操作,從而避免創(chuàng)建不同線程子類的開銷?

                  So my question is: do I need to create a specific worker thread for every operation I wish to do or is there a way of having a single thread class that I can use to carry out different operations at different times and therefore avoid the overhead of creating different thread sub-classes?

                  推薦答案

                  你可以做的是設(shè)計(jì)一個對象來完成所有這些任務(wù)(繼承 QObject 用于槽/信號).假設(shè)每個任務(wù)都定義為一個單獨(dú)的函數(shù) - 讓我們將這些函數(shù)指定為插槽.

                  What you can do is design an object to do all these tasks (inherit QObject for slots / signals). Lets say each task is defined as a separate function - lets designate these functions as slots.

                  那么(事件的一般順序):

                  Then (a general order of events):

                  • 實(shí)例化一個 QThread 對象.
                  • 實(shí)例化你的類.
                  • 使用 YouClass->moveToThread(pThread) 將您的對象移動到線程中.
                  • 現(xiàn)在為每個插槽定義一個信號,并將這些信號連接到對象中的相關(guān)插槽.
                  • 最后使用 pThread->start()
                  • 運(yùn)行線程
                  • instantiate a QThread object.
                  • instantiate your class.
                  • Move your object into the thread using YouClass->moveToThread(pThread).
                  • Now define a signal for each slot and connect these signals to the relevant slots in your object.
                  • Finally run the thread using pThread->start()

                  現(xiàn)在您可以發(fā)出信號以在線程中執(zhí)行特定任務(wù).您不需要子類 QThread 只需使用從 QObject 派生的普通類(這樣您就可以使用槽/信號).

                  Now you can emit a signal to do a particular task in the thread. You do not need to sub-class QThread just use a normal class derived from QObject (so that you can use slots/signals).

                  您可以在一個線程中使用一個類來執(zhí)行許多操作(注意:它們將被排隊(duì)).或者在多個線程中創(chuàng)建多個類(以并行"運(yùn)行).

                  You can either use one class in one thread to do many operations (note: they will be queued). Or make many classes in many threads (to run "parallel").

                  我不太了解python,無法在這里嘗試示例,所以我不會:o

                  I don't know python well enough to attempt an example here so I won't :o

                  注意:子類 QThread 的原因是如果您想擴(kuò)展 QThread 類的功能 - 即添加更多/特定的線程相關(guān)功能.QThread 是一個控制線程的類,并不意味著用于運(yùn)行任意/通用任務(wù)......即使你可以濫用它來這樣做,如果你愿意:)

                  Note: The reason to sub-class QThread would be if you wanted to extend the functionality of the QThread class - i.e. add more/specific thread-related functions. QThread is a class that controls a thread, and is not meant to be used to run arbitrary/generic tasks... even though you can abuse it to do so if you wish :)

                  這篇關(guān)于所有任務(wù)的單個工作線程還是多個特定工作人員?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進(jìn)度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動時,yaxis 刻度標(biāo)簽應(yīng)該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進(jìn)度條?)
                    <bdo id='C0L30'></bdo><ul id='C0L30'></ul>

                        <tfoot id='C0L30'></tfoot><legend id='C0L30'><style id='C0L30'><dir id='C0L30'><q id='C0L30'></q></dir></style></legend>
                      1. <small id='C0L30'></small><noframes id='C0L30'>

                          <tbody id='C0L30'></tbody>

                          <i id='C0L30'><tr id='C0L30'><dt id='C0L30'><q id='C0L30'><span id='C0L30'><b id='C0L30'><form id='C0L30'><ins id='C0L30'></ins><ul id='C0L30'></ul><sub id='C0L30'></sub></form><legend id='C0L30'></legend><bdo id='C0L30'><pre id='C0L30'><center id='C0L30'></center></pre></bdo></b><th id='C0L30'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='C0L30'><tfoot id='C0L30'></tfoot><dl id='C0L30'><fieldset id='C0L30'></fieldset></dl></div>
                            主站蜘蛛池模板: 毛片a级毛片免费播放100 | 亚洲午夜视频在线观看 | 91精品国产综合久久久亚洲 | 欧美日韩国产精品一区 | 中文在线一区二区 | 亚洲精品性视频 | 青青草免费在线视频 | 亚洲日韩第一页 | 91精品久久久久久综合五月天 | 欧美在线一区二区三区 | 91国内外精品自在线播放 | 精品一级电影 | 国产成人精品综合 | 国产区精品| 99精品久久久久久中文字幕 | 欧美一区免费 | 日韩精品一区二区三区 | 中文字幕亚洲无线 | 亚洲一区二区三区视频 | 成人在线视频网站 | 精品国产乱码久久久久久闺蜜 | 亚洲成人免费视频 | 三级av在线 | 久久久成人动漫 | 中文字幕在线网 | 亚洲一一在线 | 男女激情网站免费 | 欧美中文字幕一区 | 91在线播 | 黄色一级免费看 | 日韩一区二区福利 | 午夜影院 | 日本不卡一区 | 中文在线观看视频 | 精品国产三级 | 亚洲一区二区三区在线观看免费 | 黄色一级网 | 日韩精品久久一区二区三区 | 毛片一区二区三区 | 久久国产精品视频 | 午夜精品久久久久久久久久久久久 |