|Subject:||IdSMTP and OnWork|
|Posted by:||Alex Ivlev (email@example.com)|
|Date:||Mon, 17 Jan 2005|
I create a test RFC-822 message to 1 recepient, consisting of some short
text and an attachment, total size 4 MB. I load it into a TIdMessage and
send it via a TIdSMTP component. I assign an OnWork event to that TIdSMTP
component with the purpose of updating a progress bar. During the execution
of Send() my OnWork handler gets called exactly 3 times, with
AWorkMode=wmWrite and AWorkCount values of 322, 324 and 4076996. That's ALL.
So much for tracking the progress...
Tracing... TIdSMTP.Send() does some small processing and calls
InternalSend(), which calls SendPipelining(), which calls
TIdMessageClient.SendMsg(), which is where the interesting part starts.
(IdMessageClient.pas, rev 1.85, line 1307):
procedure TIdMessageClient.SendMsg(AMsg: TIdMessage; AHeadersOnly: Boolean =
if AMsg.NoEncode then begin
if not AHeadersOnly then begin
finally EndWork(wmWrite); end;
end else begin
if (not AHeadersOnly) then begin
My message has NoEncode=True, although I don't think that matters because
the 'else' part also just calls BeginWork() and EndWork() inside
SendHeader/SendBody. Looks like OnWork() or DoWork() is simply not getting
called at any point during the IOHandler.Write() execution. And then
EndWork() gives an update at the end. But that defies the purpose of the
OnWork() event, doesn't it? Can this be fixed somehow?