StopAllThreads Method

Stop all worker threads in FastSender object.

[Syntax]
C++: HRESULT StopAllThreads()
Visual Basic: StopAllThreads() 
C#: void StopAllThreads()

Remarks

This method must be invoked before application exits. Because StopAllThreads method terminates all threads immediately, so please make sure that GetCurrentThreads is equal to GetIdleThreads before invoking StopAllThreads method, otherwise all emails in queue would be lost.

How does FastSender work?

FastSender has an inner threading pool based on MaxThreads count. Firstly, Send or SendByPickup submits email to FastSender mail queue. Secondly threading pool retrieves email from mail queue and send it out. Finally OnSent event informs that the email was sent successfully or unsuccessfully.

No. of worker threads in the threading pool of FastSender is automatically adjusted based on the actual usage. The maximum no. of worker threads is up to the value of MaxThread property specified.

Usage Example:

[Visual Basic]
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  m_oFastSender.ClearQueuedMails
  Do While Not (m_oFastSender.GetIdleThreads() = m_oFastSender.GetCurrentThreads())
        DoEvents
  Loop
  m_oFastSender.StopAllThreads
End Sub
[C#]
private void StopAll()
{
  m_oFastSender.ClearQueuedMails();
  while( !(m_oFastSender.GetIdleThreads() == m_oFastSender.GetCurrentThreads()))
    Application.DoEvents();
    
  m_oFastSender.StopAllThreads();
}

2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.