多线程中要使用到控件的事件,请问怎么写

如果直接调用接口控制方法,会抛出异常。
这是一个陷阱。
别相信。
不要这样做。
使用 Invoke 或 BeginInvoke 封装更新代码。
在WinForm框架中,事件响应函数必须通过Invoke或BeginInvoke更新控件。
从线程更新 TextBox 的正确方法: 夏普 this.BeginInvoke(new Action(() => textBox1 .Text = "New Text"));
实用说明:始终通过 Invoke/BeginInvoke 操作 UI 控件。

Python协程之asyncio

从 Python 3 .7 开始,使用 asyncio.run(main()) 直接运行主协程。
在 Python 3 .6 中,您必须手动检索事件循环。
协程(async def)使用await来等待其他协程,并使用sleep来模拟IO阻塞。
协程对象参与事件循环(loop.create_task())来执行。
3 .7 中的 asyncio.create_task() 比 3 .6 中的 asyncio.ensure_future() 更容易。
asyncio.gather(tasks) 同时执行多个协程并返回结果列表。
asyncio.wait(tasks) 等待多个协程完成而不返回结果列表。