UpdateData(False)在线程中不起作用?

编程入门 行业动态 更新时间:2024-10-15 10:20:06
本文介绍了UpdateData(False)在线程中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 在我的应用程序中,我使用了两个线程,一个线程发送语音,另一个线程接收语音.现在我需要找到语音数据字节的发送/接收方式.要定期更新它,我在线程循环内使用UpdateData(False),但是我遇到了一个错误.因此,请让我知道如何解决此问题.我使用了Windows Thread. 我尝试了cnewDlg * ptr =(CnewDlg *)lpParam; ptr-> UpdateData(FALSE);这个,但是我得到断言失败 在此先感谢您的宝贵意见...

解决方案

仅从创建对话框及其控件的同一线程(GUI线程)调用UpdateData来自任何工作线程.如果要定期更新对话框,请使用计时器( SetTimer [ ^ ]/ CWnd: :SetTimer [ ^ ])或发送/发布( SendMessage [ ^ ]/ PostMessage [ ^ ])消息从辅助线程发送到对话框.另外,如果发送/发布消息,请尝试使用要发送/发布消息的窗口的句柄,而不是将指向任何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)在线程中不起作用?

本文发布于:2023-11-24 01:15:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623437.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   中不   UpdateData   False

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!