//return how many messages are received public int Receive() { var wrapper = new RestfulHelper() .ReceiveSMSAsync(m_config.UrlReceiveSMS, AccessToken) .GetAwaiter() .GetResult(); foreach (var sms in wrapper.InboundSmsMessageList.InboundSmsMessage) { SMSMessage msg = new SMSMessage(); msg.ID = Guid.NewGuid(); msg.MessageID = sms.MessageId; msg.SubMessageID = null; msg.SMSType = "1"; msg.SenderCode = sms.SenderAddress; msg.ReceiverCode = sms.DestinationAddress; msg.Status = "4"; //recieved msg.CreateTime = DateTime.Now; msg.SendTime = null; msg.Message = sms.Message; msg.IsDone = 0; m_msgBox.PostMessage(msg); } int smsCount = 0; Int32.TryParse(wrapper.InboundSmsMessageList.NumberOfMessagesInThisBatch, out smsCount); return(smsCount); }