跨线程调用 [英] cross thread calls

查看:60
本文介绍了跨线程调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

萨拉姆!
我正在使用thred显示进度条以进行处理.
已经启动了一个线程.
我已经在form的LOAD事件中启动了线程.然后调用s函数,在函数"END SUB"的结尾处正在中止线程.
现在我想关闭此表单,但是在异常终止线程后正在调用ME.CLOSE,但它不起作用.
如何关闭表格?

Salam!
i am using thred to display the progress bar for processing.
have started a thread.
i have started the thread in the LOAD event of the form.then calling s function, At the end of function "END SUB" am aborting the thread.
now i want to close this form but after aborting thread am calling ME.CLOSE but its not working.
how to close the form??
Can any one help??

推荐答案

您可以停止线程,也可以使用委托来避免跨线程错误.表单加载事件中还有一个选项,您可以设置

CheckForIllegalCrossThreadCalls = False

但是从编程的角度来看,建议不设置CheckForIllegalCrossThreadCalls = False.
You can stop thread or you can use delegate to avoid cross thread errors. One more option is there in form load event you can set

CheckForIllegalCrossThreadCalls = False

But to set CheckForIllegalCrossThreadCalls = False is not advisable from programming point of view.


Salam!
感谢您的答复.
我已经完成了probelm.我正在主线程中创建线程并中止该线程,然后中止该线程后将不允许执行另一条语句.
我所做的是我再次调用了主线程,然后关闭了表单.
和它的完成.

问候.
Salam!
Thanks for reply.
i am done with the probelm .i am creating the thread in the main thread.and aborting the thread then after aborting the thread will not allow execute another statement.
what i have did is that i have invoke the main thread again and then close the form.
and ITS DONE.

Regards.


这篇关于跨线程调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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