UpdateData(False)在线程中不起作用? [英] UpdateData(False) is not working in Thread?

查看:143
本文介绍了UpdateData(False)在线程中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
在我的应用程序中,我使用了两个线程,一个线程发送语音,另一个线程接收语音.现在我需要找到语音数据字节的发送/接收方式.要定期更新它,我在线程循环内使用UpdateData(False),但是我遇到了一个错误.因此,请让我知道如何解决此问题.我使用了Windows Thread.


我尝试了cnewDlg * ptr =(CnewDlg *)lpParam;
ptr-> UpdateData(FALSE);这个,但是我得到断言失败


在此先感谢您的宝贵意见...

解决方案

仅从创建对话框及其控件的同一线程(GUI线程)调用UpdateData来自任何工作线程.如果要定期更新对话框,请使用计时器( ^ ]/ CWnd: :SetTimer [ ^ ])或发送/发布( ^ ]/ ^ ])消息从辅助线程发送到对话框.另外,如果发送/发布消息,请尝试使用要发送/发布消息的窗口的句柄,而不是将指向任何CWnd后代(如CDialog)的指针移交给线程并调用其方法.

HI Guys,
In my application i am using two thread one to transmit voice and another to receive voice. Now i need to find how bytes of voice data send/receive.to update it regularly i am using UpdateData(False) inside the thread loop but i am getting an error . So pls let me know how to overcome this problem .I used windows Thread.


I tried cnewDlg* ptr=(CnewDlg*)lpParam;
ptr->UpdateData(FALSE); this but i am getting Assertion Failure


Thanks in Advance for ur Valuable comments...

解决方案

Call UpdateData only from the same thread that created the dialog and its controls (the GUI thread), not from any worker threads. If you want to update your dialog regularly, either use a timer (SetTimer[^]/CWnd::SetTimer[^]) or send/post (SendMessage[^]/PostMessage[^]) messages towards your dialog from the worker thread. Also, if sending/posting messages, try using the handles of the windows you are trying to send/post messages to rather then handing the pointers to any CWnd-descendants (like CDialog) over to the thread and calling its methods.


这篇关于UpdateData(False)在线程中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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