| Author |  | 
      
        | steve Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          Hi
           | Posted: 28 July 2005 at 8:33am | IP Logged |   |  
           | 
 |  I'm having problems with the pop3 object - VB.NET. My program is a vb form that connects to a secure pop3 inbox and gets messages (and all works fine).
 My problem lies in that if I close the application whilst the connection is being negotiated then it all appears to close, however the nameOfApp.exe in the task manager is still active and its still doing its thing.
 I've got opop3.enableEvents = True and I've tried forcing abort in the form_closing event - still no luck. One thing I have noticed tho, when you opop3.abort the errcode should go to 7, well it doesnt.
 Is there a bug or am I doing it wrong;
 sample code:
 
 Dim WithEvents oPOP3 As New MailBee.POP3()
 
 Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 oPOPSSL.LicenseKey = frmSettings.txtSSLKey.Text
 With oPOP3
 .EnableEvents = True
 .LicenseKey = frmSettings.txtSMTPKey.Text
 .PortNumber = frmSettings.txtPop3Port.Text
 .ServerName = frmSettings.txtPop3Server.Text
 .UserName = frmSettings.txtLoginUsername.Text
 .Password = frmSettings.txtLoginPassword.Text
 .SSL = oPOPSSL
 End With
 oPOP3.Connect()
 ...
 End Sub
 
 Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
 Dim blnResult As Boolean
 blnResult = oPOP3.Abort()
 Do While oPOP3.ErrCode <> 7
 Application.DoEvents()
 Loop
 MsgBox("errcode is 7")
 e.Cancel = True
 End Sub
 
 
 It never gets out of the loop. The result of the boolean is True. Where am going wrong?
 
 
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          You must remove DoEvents loop after oPOP3.Abort to allow MailBee complete with aborting its processing.
           | Posted: 28 July 2005 at 8:53am | IP Logged |   |  
           | 
 |  
 Why this is required. When .EnableEvents=True, MailBee periodically calls DoEvents during lenghty tasks. When this DoEvents is called, events like FormClose get chance to execute. Once all events are processed, DoEvents finishes and isAborted status is checked. Thus, if event handler called POP3.Abort, MailBee will abort processing after event handler has returned control to the caller. But your event handler with DoEvents loop inside never returns control and event handler never ends, and dead-lock occurs.
 
 You can find VB.NET POP3 example which correctly calls POP3.Abort in 'MailBee/MailBee Programming Samples/VB.NET/POP3 Demo #2' folder of Programs menu.
 
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | steve Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          Thanks Alex, I'll give it a go
           | Posted: 28 July 2005 at 9:11am | IP Logged |   |  
           | 
 |  Great product by the way
 | 
       
        | Back to Top |     | 
       
       
        |  |