急请教下PostThreadMessage消息丢失问题!!
程序启动三个线程,A,B,C,A和B分别发送消息(用posthreadmessage)给C,在C 中getmessage时候发现总是没法两个消息都收到,要么收到A的,要么收到B的,
代码:
private int SQLThreadId = 0;
private Thread SQL_Thread;
int s1,s2;
public struct tagMSG
{
public int hwnd;
public uint message;
public int wParam;
public long lParam;
public uint time;
public int pt;
}
public tagMSG msg1;
private Thread SQL_Thread2;
private Thread SQL_Thread3;
public void SQL1_ThreadExectue()
{
while (SQLThreadId==0)
Thread.Sleep(50);
s1=PostThreadMessage(SQLThreadId, WM_CX1, 1, 1);
}
public void SQL2_ThreadExectue()
{
while (SQLThreadId==0)
Thread.Sleep(50);
s1=PostThreadMessage(SQLThreadId, WM_CX2, 1, 1);
}
{
public void SQL_Thread3Exectue()
{
SQLThreadId = GetCurrentThreadId();
int dwRtn;
while ((dwRtn = GetMessage(ref msg1, 0, 0, 0)) != 0)
{
if (dwRtn == -1)
{ }
else
{
switch (msg1.message)