简体   繁体   English

从MFC中的工作线程调用Beginwaitcursor函数

[英]calling Beginwaitcursor function from worker thread in MFC

Can someone help me in understanding the worker threads in VC++(MFC)? 有人可以帮助我了解VC ++(MFC)中的工作线程吗? Following is my workerthread function 以下是我的workerthread函数

UINT ThreadFunc(LPVOID pParam)
{
// some initialization... etc..

AfxGetApp()->BeginWaitCursor();

...
..
/// some operations

AfxGetApp()->End WaitCursor();

}

Is it okay to call WaitCursor() functions from a worker thread? 从工作线程调用WaitCursor()函数可以吗?

The documentation available for BeginWaitCursor and EndWaitCursor make no mention of issues related to threading. 可用于BeginWaitCursorEndWaitCursor的文档没有提及与线程相关的问题。

The one thing that is mentioned, 提到的一件事,

The actions of BeginWaitCursor are not always effective outside of a single message handler as other actions, such as OnSetCursor handling, could change the cursor. BeginWaitCursor的操作在单个消息处理程序之外并不总是有效的,因为其他操作(例如OnSetCursor处理)可能会更改光标。

Other threads can change the cursor as well while your worker thread is working. 当工作线程正在工作时,其他线程也可以更改光标。

Also you need to consider the actions of the CWnd message handler OnSetCursor() which handles the WM_SETCURSOR message if the ON_WM_SETCURSOR() macro is added to the message map for a CWnd derived class. 另外,如果将ON_WM_SETCURSOR()宏添加到CWnd派生类的消息映射中,则还需要考虑CWnd消息处理程序OnSetCursor()的操作,该处理程序处理WM_SETCURSOR消息。 See Prevent MFC application to change cursor back to default icon 请参阅防止MFC应用程序将光标更改回默认图标

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM