'PySide2 How to relaunch run( ) function in second QThread?
There is some functionality class (let name is FuncClass), which will be moved to QThread (let name it second_thread). FuncClass has the run() function, which connects with second_thread starting event. After some movements, function run() ends, and second_thread continue to live in background up to end the main program. I want to reuse this thread. I want to relaunch the run() function in FuncClass this thread, and i want to do it as fast as possible, but after some event in main_thread only.
As example, i have a chat. From main_thread i create the second_thread (at program start), and move my FuncClass object (chat backend functions) to this second_thread. I have connection between send_button_click and run() function in the second_thread. After pushing the send button my message will be processed, run() function will reach it's end, second thread will continue working, but, i actually can't restart the run() function with new button_send_click.
(I don't want to use endless loops in run() function, because i don't want to burn my cpu with useless loops, while waiting button_send_click, but i still need high speed response from this function (like activating at first time. ))
And that's why i don't want to use pack of these functions below to restart the thread execution (too long and freezes main_gui).
thread.exit()
thread.wait()
thread.start()
How can i restart the function as fast as possible, without endless check-loops and freezing main_gui?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
