螺纹锁形式 [英] thread locks form

查看:87
本文介绍了螺纹锁形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我正在构建一个发送电子邮件的简单程序.该程序有2个按钮启动和取消.如果我单击开始",它将创建一个线程,开始发送电子邮件并在我按取消"时更新进度条,它将停止该线程.

现在,我设法创建了线程,但是由于它是在另一个线程中创建的,因此它无法访问进度条.

为了解决这个问题,我实现了调用问题,就是使用调用它会锁定程序,就像根本不使用线程一样.

我需要知道如何解决这一紧急情况.

Cumpz,

Hello,


I''m building a simple program that sends emails. The program has 2 buttons start and cancel. If i click start it creates a thread a start sending email and updating a progress bar when i press cancel it stops the thread.

Now, i''ve managed to create the thread but it can''t access the progress bar because it was created in another thread.

To solve this i''ve implement invoke the problem is that using invoke it locks the program similar to not be using threads at all.

I need to know how to fiz this urgent.

Cumpz,

推荐答案

您是否已阅读以下资源:

http://www.tek-tips.com/faqs.cfm?fid=5162 [ ^ ]


http://www.codeguru.com/forum/showthread.php?t=312454 [ ^ ]


http://stackoverflow. com/questions/391125/how-to-change-pane-text-of-status-bar-from-a-thread-in-mfc [
Did you read these resources:

http://www.tek-tips.com/faqs.cfm?fid=5162[^]


http://www.codeguru.com/forum/showthread.php?t=312454[^]


http://stackoverflow.com/questions/391125/how-to-change-pane-text-of-status-bar-from-a-thread-in-mfc[^]

Hope it helps.


我确定Amir的链接中有1个说了这一点,但只需使用PostMessage [
Im sure 1 of Amir''s links says this, but just use PostMessage[^] (instead of SendMessage) to update the progress bar from the thread. This places the request on the applications message queue, which is processed by the main thread.


这篇关于螺纹锁形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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