private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { try { IMessageIndicationObject obj = e.IndicationObject; if (obj is MemoryLocation) { MemoryLocation loc = (MemoryLocation)obj; string logmsg = string.Format("New message received in storage \"{0}\", index {1}.", loc.Storage, loc.Index); logger(logmsg); DecodedShortMessage msg = comm.ReadMessage(loc.Index, loc.Storage); ShowMessage(msg.Data); return; } if (obj is ShortMessage) { ShortMessage msg = (ShortMessage)obj; SmsPdu pdu = comm.DecodeReceivedMessage(msg); logger("New message received:"); ShowMessage(pdu); return; } logger("Error: Unknown notification object!"); } catch (Exception ex) { ShowException(ex); } }
private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { var obj = e.IndicationObject; if (obj is MemoryLocation) { MemoryLocation loc = obj as MemoryLocation; try { var msg = comm.ReadMessage(loc.Index, loc.Storage); comm.DeleteMessage(msg.Index, PhoneStorageType.Sim); var d = (SmsDeliverPdu)msg.Data; if (d.OriginatingAddress != null) { this.Invoke((Action)(() => { lock (listDo) { listDo.Add((SmsDeliverPdu)msg.Data); }; })); this.Invoke((Action)(() => { MessageReceived(msg); })); } } catch (Exception ex) { this.Invoke(new Action(() => ShowException(ex))); } } }