Windows Messag handling in C#
C#
2
Posts
2
Posters
0
Views
1
Watching
-
Hi, Is there any C# equivalent for SDK function 'MsgWaitForMultipleObjects()'? I want to implement this following c++ code in c#. Which is the right path to follow.
bool CMyClass::MyFun() { unsigned threadID; DWORD waitResult; MSG msg; writeSuccess = false; hThread = (HANDLE)_beginthreadex(NULL, 0,writeThread, NULL,0,&threadID); if (!hThread) return false; waitResult = MsgWaitForMultipleObjects(1, &hThread, FALSE, INFINITE, QS_ALLINPUT); while (waitResult != WAIT_OBJECT_0) { if (waitResult == WAIT_OBJECT_0 + 1) while (PeekMessage(&msg, NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (waitResult == WAIT_FAILED) { //An error occured, we need to handle it here break; } waitResult = MsgWaitForMultipleObjects(1, &hThread, FALSE, INFINITE, QS_ALLINPUT); } CloseHandle(hThread); hThread = NULL; return writeSuccess; }
I have read about the
IMessageFilter
interface ofMicrosoft.Win32
namespace. Is this the right way to proceed on this. Kindly advise. Vini -
Hi, Is there any C# equivalent for SDK function 'MsgWaitForMultipleObjects()'? I want to implement this following c++ code in c#. Which is the right path to follow.
bool CMyClass::MyFun() { unsigned threadID; DWORD waitResult; MSG msg; writeSuccess = false; hThread = (HANDLE)_beginthreadex(NULL, 0,writeThread, NULL,0,&threadID); if (!hThread) return false; waitResult = MsgWaitForMultipleObjects(1, &hThread, FALSE, INFINITE, QS_ALLINPUT); while (waitResult != WAIT_OBJECT_0) { if (waitResult == WAIT_OBJECT_0 + 1) while (PeekMessage(&msg, NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (waitResult == WAIT_FAILED) { //An error occured, we need to handle it here break; } waitResult = MsgWaitForMultipleObjects(1, &hThread, FALSE, INFINITE, QS_ALLINPUT); } CloseHandle(hThread); hThread = NULL; return writeSuccess; }
I have read about the
IMessageFilter
interface ofMicrosoft.Win32
namespace. Is this the right way to proceed on this. Kindly advise. Vini