void _UpdateResult( ref SmtpClient oSmtp, ref SmtpClientAsyncResult oResult ) { //Get the item index from Tag property int index = (int)oSmtp.Tag; try { if( !chkTestRecipients.Checked ) { oSmtp.EndSendMail( oResult ); _CrossThreadSetItemText( "Completed", index ); } else { oSmtp.EndTestRecipients( oResult ); _CrossThreadSetItemText( "PASS", index ); } m_nsuccess++; } catch( SmtpTerminatedException exp ) { string err = exp.Message; _CrossThreadSetItemText( err, index ); m_nfailure++; } catch( SmtpServerException exp ) { string err = String.Format( "Exception: Server Respond: {0}", exp.ErrorMessage ); _CrossThreadSetItemText( err, index ); m_nfailure++; } catch( System.Net.Sockets.SocketException exp ) { string err = String.Format( "Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message ); _CrossThreadSetItemText( err, index ); m_nfailure++; } catch( System.ComponentModel.Win32Exception exp ) { string err = String.Format( "Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message ); _CrossThreadSetItemText( err, index ); m_nfailure++; } catch( System.Exception exp ) { string err = String.Format( "Exception: Common: {0}", exp.Message ); _CrossThreadSetItemText(err, index ); m_nfailure++; } m_nsent++; status.Text = String.Format( "Total {0}, Finished {1}, Succeeded {2}, Failed {3}", m_ntotal, m_nsent, m_nsuccess, m_nfailure); }