我试图从线程启动winForm,但是当我这样做时,表单显示但没有任何标签被加载(背景应该是白色)并且表单被冻结.
I am trying to start a winForm from a thread, but when i do so, the form show but none of the labels are loaded ( the background where they should be is white ) and the form is frozen.
我已经用其他winForms尝试过了,我知道它可以正常工作,但似乎仍然不起作用?有人遇到过这个问题吗?
I've tried it with some other winForms that i know that work just fine and it still doesn't seem to work ? Has anyone encountered this problem ?
我知道这个问题含糊不清,但实际上我没有任何特定的代码可以帮助您理解问题.
I know the question is vague but there isn't really any specific code that I could give to help understand the problem.
推荐答案这是因为Message Loop仅在UI线程上运行.并且在任何其他线程中创建控件或窗口时,它都无法访问该消息循环.因此,无法处理用户输入.
That is because the Message Loop runs on UI thread only. And when a control or window is created in any other thread, it cannot access that message loop. And thus, cannot process user input.
要解决此问题,请尝试从UI线程创建一个窗口,然后从该窗口创建一个线程,以执行您想在其他线程中执行的任何操作.
To solve this, try creating a window from UI thread and create a thread from that window to do whatever you want to do in different thread.
更多推荐
无法从线程启动winForm
发布评论