PyQt/多线程使用/README.md
2018-03-14 16:24:04 +08:00

16 lines
No EOL
578 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 简单的子线程例子
使用继承QThread和moveToThread两种方式
# 注意,这里只是简单演示,在应用这些代码时要小心
## 线程的挂起与恢复
这里使用windows的api实现主要用到SuspendThread和ResumeThread函数
利用ctypes.windll.kernel32.OpenThread(win32con.PROCESS_ALL_ACCESS, False, int(QThread.currentThreadId()))
得到线程的句柄,然后就可以通过上面的两个函数对其进行挂起与恢复
ctypes.windll.kernel32.TerminateThread终止线程不推荐
## 截图
![截图](ScreenShot/1.gif)