BCB6: OnWork *before* OnWorkBegin

Giganews Newsgroups
Subject: BCB6: OnWork *before* OnWorkBegin
Posted by:  poojo hackma (poojo.com/mail)
Date: Tue, 28 Feb 2006

Hi,

I have an Indy 9 on BCB6, and I am seeing a strange bug in *my* code that I
can not resolve:

Whenever I Get() a file from the FTP site, OnWorkBegin fires first with a
PostMessage back to my main form.  Later, OnWork fires with a PostMessage
back to my main form.  Here is the simple code:

//---------------------------------------------------------------------------
void __fastcall ZFtpThread::FtpWorkBegin(TObject *Sender, TWorkMode
AWorkMode,
                            const int AWorkCountMax) {
  PostMessage(hMain, FTH_WBEGIN, AWorkMode, (AWorkCountMax) ? AWorkCountMax
: iFileSize);
}
//---------------------------------------------------------------------------
void __fastcall ZFtpThread::FtpWork(TObject *Sender, TWorkMode AWorkMode,
                            const int AWorkCount) {
  PostMessage(hMain, FTH_WORK, AWorkMode, AWorkCount);
}
//---------------------------------------------------------------------------

The problem is that the posts show up in the wrong order in my main form,
that is FTH_WORK is received by the main form's WndProc routine before
FTH_WBEGIN is.

I have checked, and FTH_WBEGIN and FTH_WORK are not crossed in their
definitions.  This is a strange bug!

Does anyone know why this would be behaving this way?  I have used Indy in
the past (same version) for a similar routine (in fact, I copied the code
for it to make this one), but it did not behave this way.

Thanks in advance,
poojo

Replies