Delphi中的线程类--之(5,大结局)[5]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 raptor 的 blog

  msg: tmsg;

begin

  h[0] := fhandle;

  if getcurrentthreadid = mainthreadid then

  begin

    waitresult := 0;

    h[1] := syncevent;

    repeat

      { this prevents a potential deadlock if the background thread

        does a sendmessage to the foreground thread }

      if waitresult = wait_object_0 + 2 then

        peekmessage(msg, 0, 0, 0, pm_noremove);

      waitresult := msgwaitformultipleobjects(2, h, false, 1000, qs_sendmessage);

      checkthreaderror(waitresult <> wait_failed);

      if waitresult = wait_object_0 + 1 then

        checksynchronize;

    until waitresult = wait_object_0;

  end else waitforsingleobject(h[0], infinite);

  checkthreaderror(getexitcodethread(h[0], result));

end;

本文关键:Thread Event CriticalSection Synchronize
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top