1

I use this code for receive sms,but sometimes it does not work,it means it can not understand sms receive.what can i do that every time it works:

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("");
}
tshepang
  • 12,111
  • 21
  • 91
  • 136
amertat
  • 33
  • 3
  • 11
  • 3
    You need to post more details of the problem. Is it getting an exception? Which line does it fail on? What's the stack trace? Have you attached a debugger when it fails to see what the state of things are? – Paolo Jan 08 '13 at 08:13
  • What library are you using to? `GsmComm.GsmCommunication` is not part of the core framework... – Greg B Jan 08 '13 at 08:33
  • @ Greg B:I use GSMCommunication,what do u mean GsmComm.GsmCommunication is not part of the core framework? – amertat Jan 08 '13 at 09:55
  • @Paolo:It does not give me error,just sometimes!! it does not execute comm_MessageReceived()!! – amertat Jan 08 '13 at 09:58
  • Ok, so the problem presumably lies somewhere in the GsmComm library. Greg B means it's not part of the standard .NET libraries that come out the box - it must be a 3rd party library, which is it? – Paolo Jan 08 '13 at 10:26
  • @Paolo:tanx paolo for your attention ,I use GSMCommunication library – amertat Jan 09 '13 at 07:02

0 Answers0