Re: [twsocket] SMTPCli and COM inprocess DLL

2009-07-29 Thread Arno Garrels
Markus Humm wrote:

 Ok, but I think I already obeyed to this. 

The correct sequence was ThreadDetach in context of the
thread that created the data module, later in TThread.Execute:

MyIcsObject.ThreadAttach 
try
AssignEventHandlers;
CallAsyncMethod;
PumpMessages until SessionClosed;
finally
MyIcsObject.ThreadDetach;
end;

ThreadDetach destroys the hidden window and ThreadAttach creates
a new one. Special care must be taken to not use property Handle
while no window handle is allocated since this silently created a
new one ( at least since ICS V6 ).
ICS events are always executed in the context of the thread that 
created the hidden window! 

 Let's see what the dynamic
 creation will bring. 

It works reliable, I use TSmptCli and other ICS components in worker
threads since many years successfully.  

 I suppose I don't need any thread attach/detach
 then when I do it inside execute?

Correct, just create and destroy the object in TThread.Execute, very
easy.

--
Arno Garrels 
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SMTPCli and COM inprocess DLL

2009-07-28 Thread Markus Humm
Hello,

 my D2007 ICS V5 based app uses SmtpCli in a COM server DLL which was
 formerly a real exe file with a mostly hidden VCL main form and thus a
 separate message loop. But the SmtpCli was bound to its own thread via
 setting multithreaded to true and threaddetaching and threadattaching
 it to this secondary thread.

 Why don't you create the SmtpCli object in TThread's Execute method?
 No need to fiddle around with ThreadAttach/ThreadDetach.

Because I simply had placed the component on my datamodule which seems
easier at the time I did this. But I try to change it today if time permits.

 This architecture now seems to make problems after changing to a in
 process DLL and getting rid of that VCL mainform which was only used
 for debugging anyway.

 Has anybody any experience?

 No, not with SMTPCli in a DLL.

 I get errors like cannot detach from
 thread or attach to annother thread or so.

 That's the point, a window handle can only be deallocated in
 the context
 of the thread that created it.

Ok, but I think I already obeyed to this. Let's see what the dynamic
creation will bring. I suppose I don't need any thread attach/detach
then when I do it inside execute?

Greetings

Markus
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SMTPCli and COM inprocess DLL

2009-07-27 Thread Arno Garrels
Markus Humm wrote:
 Hello,
 
 my D2007 ICS V5 based app uses SmtpCli in a COM server DLL which was
 formerly a real exe file with a mostly hidden VCL main form and thus a
 separate message loop. But the SmtpCli was bound to its own thread via
 setting multithreaded to true and threaddetaching and threadattaching
 it to this secondary thread.

Why don't you create the SmtpCli object in TThread's Execute method?
No need to fiddle around with ThreadAttach/ThreadDetach.

 
 This architecture now seems to make problems after changing to a in
 process DLL and getting rid of that VCL mainform which was only used
 for debugging anyway.
 
 Has anybody any experience? 

No, not with SMTPCli in a DLL.

 I get errors like cannot detach from
 thread or attach to annother thread or so.

That's the point, a window handle can only be deallocated in the context
of the thread that created it.

--
Arno Garrels  


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be