我使用此代码接收短信,但有时它不起作用,这意味着它无法理解短信接收。每次它工作时我该怎么做:
CommSetting.comm.MessageReceived+=new MessageReceivedEventHandler(comm_MessageReceived);
private void comm_MessageReceived(object sender, GsmComm.GsmCommunication.MessageReceivedEventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
string storage = GetMessageStorage();
DecodedShortMessage[]messages=CommSetting.comm.ReadMessages(PhoneMessageStatus.ReceivedUnread , storage);
foreach(DecodedShortMessage message in messages)
{
Output(string.Format("Message status = {0}, Location = {1}/{2}",
StatusToString(message.Status),
message.Storage, message.Index));
ShowMessage(message.Data);
Output("");
}
Output(string.Format("{0,9} messages read.", messages.Length.ToString()));
Output("");
}