触发线程PostThreadMessage(mParseThread.ThreadID,WM_PARSE,0,0)
以下为线程执行体
procedure TParseCommandThread.Execute;
var
  Amsg:Msg;
  commandCode:Integer;
  mem:TMemoryStream;
begin
  inherited;
  {待调试}
  while (not terminated) do
    begin
    GetMessage(AMsg,0,0,0);
    case AMsg.message of
      WM_PARSE:
      begin
      while mCommandList.Count >= 1 do
        begin
        if PCommand(mCommandList[0]).IsOk then
          begin
          commandCode := PCommand(mCommandList[0])^.CommandCode;
          mem := PCommand(mCommandList[0])^.mem;
          case commandCode of
          1001:
            ParseCommand1001(mem);
          2001:
            ParseCommand2001(mem);
          3001:
            ParseCommand3001(mem);
          end;
          mem.Free;
          mCommandList.Delete(0);
          end
        else
          Break;
        end;
      end;
      WM_TERMINATE:Terminate;
    end;
  end;
end;
我现在改用上段程序来处理Socket.Onread时指令的顺序执行。
但是,一直获得AMsg.message=15,于是程序进入死循环?但是,我并没有发送这个消息啊,还有我在线程中发消息给其他线程,会不会有问题呢?
各位请帮我看看

解决方案 »

  1.   

    关注!
    你调试时,先用Try....
    你跟踪不到吗?
      

  2.   

    case AMsg.message of时,=15
    但是,我的程序从来就没有发消息15给mParseThread
      

  3.   

    我在线程中控制了主Form上的东东,会有问题吗?
      

  4.   

    控制主Form上的控件一定有问题,我给你分析一下,在线程中控制主窗口中的控件一定用了synchronize这个同步函数,这个时候正好主窗口有一个语句要等待synchronize函数结束,而
    synchronize函数也要等待,这样就出现死锁