Dimension
March 21st, 2005, 09:09 PM
Hi,
I read in MSDN regarding the different between both.
Now, this is my scenario.
In my worker thread, I need to send message to Main Thread to execute something and return something to me before proceed to next statement.
Which is the best way to accomplish this ?
I'm worried that using SendMessage will cause exception, as the Thread might be blocked. Using PostMessage will return immediately without waiting for the message to process finish. If you have better approach, let me know.
DWORD WINAPI SendStr (LPVOID pParam)
{
SendMessage(My_hWnd, WM_MYMESSAGE, ...);
result = myresult;
if (result != 0)
{
// do something A
}
else
{
// do something B
}
}
in Main Thread:
case WM_MYMESSAGE:
if (SendMyStr(ABC)) // Unfortunately, SendMyStr can only work in Main Thread
myresult= 1;
else
myresult = 0;
break;
Please advise. Thanks.
I read in MSDN regarding the different between both.
Now, this is my scenario.
In my worker thread, I need to send message to Main Thread to execute something and return something to me before proceed to next statement.
Which is the best way to accomplish this ?
I'm worried that using SendMessage will cause exception, as the Thread might be blocked. Using PostMessage will return immediately without waiting for the message to process finish. If you have better approach, let me know.
DWORD WINAPI SendStr (LPVOID pParam)
{
SendMessage(My_hWnd, WM_MYMESSAGE, ...);
result = myresult;
if (result != 0)
{
// do something A
}
else
{
// do something B
}
}
in Main Thread:
case WM_MYMESSAGE:
if (SendMyStr(ABC)) // Unfortunately, SendMyStr can only work in Main Thread
myresult= 1;
else
myresult = 0;
break;
Please advise. Thanks.