コード例 #1
0
 /// <summary>
 /// Receive data from the server using the established socket connection
 /// </summary>
 /// <returns>The data received from the server</returns>
 public void Receive()
 {
     try
     {
         while (!Closing.WaitOne(1))
         {
             if (m_Parent.BytesToRead > 0)
             {
                 m_Parent.GXSMS_DataReceived(m_Parent, null);
             }
             else
             {
                 Closing.WaitOne(100);
             }
         }
     }
     catch (Exception ex)
     {
         m_Parent.NotifyError(ex);
         if (!Closing.WaitOne(1))
         {
             m_Parent.Close();
         }
     }
 }
コード例 #2
0
ファイル: SMSReceiveThread.cs プロジェクト: srem/Gurux.SMS
 /// <summary>
 /// Check are there new SMSs.
 /// </summary>
 public void Receive()
 {
     try
     {
         do
         {
             if (m_Parent.IsSynchronous || m_Parent.m_OnReceived != null)
             {
                 foreach (GXSMSMessage it in m_Parent.Read())
                 {
                     if (it.Status == MessageStatus.Unread)
                     {
                         try
                         {
                             if (m_Parent.IsSynchronous)
                             {
                                 m_Parent.SyncMessage = it;
                                 m_Parent.m_SMSReceived.Set();
                                 break;
                             }
                             m_Parent.m_OnReceived(m_Parent, new Gurux.Common.ReceiveEventArgs(it, it.PhoneNumber));
                         }
                         catch (Exception ex)
                         {
                             m_Parent.NotifyError(ex);
                         }
                     }
                 }
             }
         }while (!Closing.WaitOne(m_Parent.SMSCheckInterval * 1000));
     }
     catch (Exception ex)
     {
         m_Parent.NotifyError(ex);
         if (!Closing.WaitOne(1))
         {
             m_Parent.Close();
         }
     }
 }