Updated Version of TThread.Synchronize for Delphi 6.0

This is fixed in Update 1
To use this code you will need to recompile Delphi6\source\rtl\common\Classes.pas. I would suggest the following if you absolutely require this fix. Note: This will only work if your application does not use packages. If your application does require packaged then you will have to wait for the release of the update.
  1. Copy Delphi6\source\rtl\common\Classes.pas to Delphi6\lib
  2. Open Delphi6\lib\Classes.pas in the IDE
  3. Search for TThread.Synchronize
  4. Replace it with the version below
  5. Recompile your application

// This code is for Delphi 6.0 only, if your application requires packages
// you will have to wait for the update.
procedure TThread.Synchronize(Method: TThreadMethod);
var
  SyncProc: TSyncProc;
begin
  if GetCurrentThreadID = MainThreadID then
    Method
  else
  begin
{$IFDEF MSWINDOWS}
    SyncProc.Signal := CreateEvent(nil, True, False, nil);
    try
{$ENDIF}
{$IFDEF LINUX}
      FillChar(SyncProc, SizeOf(SyncProc), 0);  // This also initializes the cond_var
{$ENDIF}
      EnterCriticalSection(ThreadLock);
      try
        FSynchronizeException := nil;
        FMethod := Method;
        SyncProc.Thread := Self;
        SyncList.Add(@SyncProc);
        ProcPosted := True;
        if Assigned(WakeMainThread) then
          WakeMainThread(Self);
{$IFDEF MSWINDOWS}
        LeaveCriticalSection(ThreadLock);
        try
          WaitForSingleObject(SyncProc.Signal, INFINITE);
        finally
          EnterCriticalSection(ThreadLock);
        end;
{$ENDIF}
{$IFDEF LINUX}
        pthread_cond_wait(SyncProc.Signal, ThreadLock);
{$ENDIF}
      finally
        LeaveCriticalSection(ThreadLock);
      end;
{$IFDEF MSWINDOWS}
    finally
      CloseHandle(SyncProc.Signal);
    end;
{$ENDIF}
    if Assigned(FSynchronizeException) then raise FSynchronizeException;
  end;
end;

Page hits: Counter