sendmail Threaded property
Return to Introduction  Previous page  Next page
Applies to
SendMail component.  

property Threaded: Boolean; // True by default  

The Threaded property used to choose between two working models of acSendMail component.  
This property specifies whether the message should be prepared and sent via Internet to SMTP server in current, caller's thread, or should create separate thread which will process the message delivery. Set Threaded to True to create separate thread, or to False if the part of code which calls the Send method are already in separate, non-interface thread.  
Basically there is two possible working models:  
1.Threaded: when Threaded is True, the component creates new separate thread to produce and send email message to specified SMTP host. In this case the SendMail does not locks the application interface when it connects to the SMTP server and sends the message via Internet, and only produce events synchronized with main application thread (interface).  
iiwarning However, in this model the component can send ONLY ONE message simultaneously, since it can create only one thread to send message. If you will try to send additional message when the component is busy, next email will not be sent, and Send method will just return False. You should implement some message queue to operate with SendMail in this threading model and don't call Send method while previous message not yet sent.  
Otherwise — set Threaded to False and use non-threaded model to send any number of email messages simultaneously from any number of different threads.  
2.Non-threaded: when Threaded is False, the component does not creates any separate thread to produce and send email message. This model should be used only if your application uses many threads which could send email message using this component. This model should NOT be used in single-threaded application, since when you call the Send method, all your application interface will be locked while the component producing and sending the email message.  

See also
Thread property;  
Send method.