private void _sendMessage(Message aMsg, MailBox aDest) { int failedSendCounter = 0; try { aMsg.Send(aDest); failedSendCounter = 0; } catch (Exception) { failedSendCounter++; App.Trace("Counter ->" + failedSendCounter.ToString()); if (failedSendCounter == 10) { terminateFlag = true; } } }
public void ProcessIncomingMessage(Message msg);
public override void OnMailBoxMessage(Message msg) { switch (state) { case TState.EStateGettingDeviceID: { state = TState.EStateInitTransfer; deviceID = GetDeviceID(); } break; case TState.EStateSwitchDevice: { state = TState.EStateInitTransfer; SendMessageToDispatcher(deviceID, Message.KMsgSuspendTransfer); deviceID = GetDeviceID(); } break; case TState.EStateInitTransfer: { ShowInfo(Message.KMsgDevRequest); switch (RequestDevice(deviceID)) { case Message.KErrNo: { if (MainMenu() != NewDevice) { state = TState.EStateTransferActive; SetDeviceParameters(); } else state = TState.EStateGettingDeviceID; } break; case Message.KErrDeviceNotRegistered: { state = TState.EStateGettingDeviceID; ShowError(Message.KErrDeviceNotRegistered); } break; case Message.KErrDeviceNotReady: { state = TState.EStateInitTransfer; ShowError(Message.KErrDeviceNotReady); } default: throw new ArgumentException("Bad message code"); } } break; case TState.EStateTransferActive: { switch (msg.Command) { case Message.KMsgReceivedData: { ProcessIncomingData(msg); } break; case Message.KMsgSetParameters: { SetDeviceParameters(); // ?????? } break; case Message.KMsgSuspendTransfer: { state = TState.EStateTransferSuspended; ShowInfo(Message.KMsgSuspendTransfer); } break; case Message.KMsgResumeTransfer: { state = TState.EStateResumeTransfer; } break; case Message.KMsgStopTransfer: { state = TState.EStateResumeTransfer; ShowInfo(Message.KMsgStopTransfer); } break; case Message.KMsgError: { switch (msg.Code) { case Message.KErrDeviceNotReady: case Message.KErrLostConnection: { state = TState.EStateResumeTransfer; ShowError(msg.Code); } break; default: { throw new ArgumentException("Bad error code"); } } } break; } } break; case TState.EStateTransferSuspended: { if (msg.Command == Message.KMsgResumeTransfer) { state = TState.EStateResumeTransfer; } else throw new ArgumentException("Bad message code"); } break; default: throw new ArgumentException("Bad state"); } }