title: IMAP 4 Client Authentication issue
body: <p>I have a windows service which is scheduled to run below method every 5minutes and read emails and process the attachement i.e. convert tiff to pdf and update the database by reading the QR code of attachement, I have observed a issue recently the Service got hanged i.e. I could not stop it from services.msc and have to kill it from task manager although it worked well for last 2months without issue.</p>
  
  <p>Upon investigating the log I observed the log entry was "IMAP 4 Client Authentication Started"
  and it never reached "IMAP 4 Client Authentication Done" although as it is schedule to call this method every 5minutes I could see the logs from there on call to the below method </p>
  
  <p>"call to processEmail for user Dept1 "</p>
  
  <p>"call to processEmail for user Dept2 "</p>
  
  <p>son on........</p>
  
  <pre><code>private readonly object _myLock = new object();
  
  public void start()
  {
        // all the belwo variable read from config file...
      Log.WriteLog("call to processEmail for user " + username);
       ProcessEmail(host, username, password, connPort);
       Log.WriteLog("Service Completed reading for user " + username);
  
  
  }
  
  public void ProcessEmail(string host, string username, string password, int connPort)
  {
              Monitor.Enter(_myLock); //_myLock defined at class level
              Log.WriteLog("IMAP 4 Client Authentication Started");
              using (Imap4Client imap = new Imap4Client())
              {
                  try
                  {
                      imap.ConnectSsl(host, connPort);          // port 993 for SSL Connect 
                      imap.Login(username, password);
                      imap.Command("capability");
                      Log.WriteLog("IMAP 4 Client Authentication Done");
  
                      //fllowed by reading email from Inbox and junk emails.      
  
                  }
                  catch (Exception ex)
                  {
                      Log.WriteLog(ex.Message);
                  }
                  finally
                  {
                      Monitor.Exit(_myLock);
                  }
  
              }
  }
  </code></pre>
  
  <p>My concern is if due to some reason  imap.Login(username, password) fails, why the code block holds the lock by not allowing other instances to login as in finally block I am releasing the lock Monitor.Exit(_myLock), and I don't even see the exception recorded in log file, does imap.Login(username, password) trying to connect for ever to login, any suggestion/help on this would be of great help.</p>
  
  <p>Again - this issue occurred today and from the log I could see this time </p>
  
  <p>Message: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.</p>
  
  <p>followed by -
                 <strong>Service Completed reading for user " + username</strong></p>
  
  <p>and then again sequentially...
  **call to processEmail for user  Dept1 **
  **call to processEmail for user  Dept2 **</p>
  
  <p>Is this issue has something to do with Activeup.Net.Imap4 client or could itbe Deadlock issue as I don't see anything that would cause deadlock..</p>