Check out the WaitForMultipleObjects windows API call. It works with an array of "Waitable" handles and you can specify a timeout.
If the component you use doesn't provide you with any "Waitable" handles, you can easily create one of your own with the CreateEvent API call and get your component to indicate success by calling SetEvent on the same handle. If you need the ability to provide an abort mechanism before the timeout has been reached, you can create another event and set that in VCL code without having to worry about synchronization issues. eg: AbortEvent := CreateEvent(nil,true,false,nil); SuccessEvent := CreateEvent(nil,true,false,nil); procedure TMyForm.btnAbortClick(sender : TObject); begin SetEvent(AbortEvent); end procedure TMyForm.SMTPComplete(Sender : TObject); begin SetEvent(SuccessEvent); end procedure TMyThread.Execute; var WaitHandles : array[0..1] of THandle; begin WaitHandles[0] := SuccessEvent; WaitHandles[1] := AbortEvent; ReturnValue := WaitForMultipleObjects(2,@WaitHandles,false,MyTimeout); if ReturnValue = WAIT_TIMEOUT then // timeout else if ReturnValue = WAIT_OBJECT_0 then // SuccessEvent Handle was set else // AbortEvent Handle was set end; HTH Trevor ----- Original Message ----- From: "Robert Martin" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Tuesday, August 13, 2002 3:46 PM Subject: [DUG]: More thread questions > The SMTP component I use to email from within a thread recommends using the > 'Blocking' transmission method for sending if used from within threads to > reduce resource usage. The downsize is that transmission timeouts are no > longer handled (effectively freezing a particular thread). The component > help suggests writing my own code to handle timeouts but I'm not sure > exactly how to do this, ant suggestions would be appreciated? > > > Rob > > Software engineer > Wild Software Ltd > Ph 03 338-1407 > > > -------------------------------------------------------------------------- - > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > > --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/