我有个主线程中要创建一个线程。线程中主要判断某个任务完成没有,是一个while循环,没执行完就等待。主线程要等子线程执行完才能往下执行,所以我用了个互斥句柄,主线程关键代码是这样子的:
 if FPlayFileHandle > 0 then
   begin
     MyThread := TMyThead.Create(True);
     MyThread.FPlayFileHandle := FPlayFileHandle;
     MyThread.Resume;
     nret := WaitForSingleObject(hMutex, INFINITE);
   ReleaseMutex(hMutex);
  end;
子线程中关键代码:
  hMutex := CreateMutex(nil, false, nil);
  while true do
  begin
    nPos := BSR_DVR_DownFileGetPos(FPlayFileHandle) div 10;
    if (npos < 0) or (npos >= 100) then
    begin
      FreeOnTerminate := True;
      CloseHandle(hMutex);
我就是不知道这样的对互斥变量操作过程能让子线程先执行完吗,网上查资料可以的,可是子线程没执行完,主线程就接着执行了,请问大家我那个地方出问题了,怎么改?