Beispiel #1
0
 public void SendException(MySmtp smtp)
 {
     lock (_lockObje)
     {
         AllSmtpClientStatus[smtp.Index] = false;
         Debug.WriteLine(" ");
         Debug.Write("Index:");
         Debug.Write(smtp.Index);
         Debug.WriteLine(" release by Exception.");
     }
 }
Beispiel #2
0
        public MySmtp GetInstance(string hostName, string userName, string psw, string domainName, SendCompletedEventHandler completeHandler, out int index)
        {
            lock (_lockObje)
            {
                Debug.Write("CurrentSmtpCount:");
                Debug.WriteLine(AllSmtpClient.Count);
                foreach (var keyValue in AllSmtpClientStatus)
                {
                    if (!keyValue.Value)
                    {
                        AllSmtpClientStatus[keyValue.Key] = true;
                        AllSmtpClient[keyValue.Key].CompletedHandler = completeHandler;

                        Debug.WriteLine(" ");
                        Debug.Write("Index:");
                        Debug.Write(keyValue.Key);
                        Debug.WriteLine(" use.");
                        index = keyValue.Key;
                        return AllSmtpClient[keyValue.Key];
                    }
                }

                MySmtp client = new MySmtp(hostName, userName, psw, domainName, AllSmtpClient.Count);
                client.EventSendCompleted += client_SendCompleted;
                AllSmtpClient.Add(client);
                AllSmtpClientStatus.Add(client.Index, true);

                Debug.WriteLine(" ");
                Debug.Write("Index:");
                Debug.Write(client.Index);
                Debug.WriteLine(" create and use.");
                index = client.Index;
                client.CompletedHandler = completeHandler;

                return client;
            }
        }