当我们从模块调用函数时,不运行线程. [英] Not run the Thread when we Calling function from module.

查看:119
本文介绍了当我们从模块调用函数时,不运行线程.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我写了一个Sub并将其放在模块中.Sub在这里:

Hi

I wrote a Sub And put it in the module.and the Sub is here:

Public Sub nnh()
    Me.Text = "%%%%"
End Sub



在单击按钮事件时,我编写的代码将无法运行!



And at the click of a button event, I wrote this code will not run!

CheckForIllegalCrossThreadCalls = False
t1 = New System.Threading.Thread(AddressOf nnh)
t1.Start()



问题出在哪里?



谢谢.



Where is the problem?



Thank you.

推荐答案

首先,删除"CheckForIllegalCrossThreadCalls"行.将其设置为False永远不是一个好主意.

除创建线程的线程(即启动线程或UI线程)外,您无法通过其他任何方式修改控件.

阅读 [
First, remove the "CheckForIllegalCrossThreadCalls" line. Setting that to False is NEVER a good idea.

You cannot modify controls from anything other than the thread that create it, namely the startup, or UI, thread.

Read this[^] to learn how to do it correctly.


F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1
F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1


这篇关于当我们从模块调用函数时,不运行线程.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆