private void intTextValidate(object sender, EventArgs e) { if (m_suppressEvent) { return; } TextBox txt = sender as TextBox; if (txt == null) { return; } int param; if (!int.TryParse(txt.Text, out param)) { if (txt == txtLength) { m_dataLength = 0; } return; } if (txt == txtDMulti) { _packetProcessActions.SetEncodeMultiples((byte)param, _packetEncoderRepository.SendMultiplier); if (param < 6 || param > 12) { MessageBox.Show("This should be between 6 and 12...", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (txt == txtEMulti) { _packetProcessActions.SetEncodeMultiples(_packetEncoderRepository.ReceiveMultiplier, (byte)param); if (param < 6 || param > 12) { MessageBox.Show("This should be between 6 and 12...", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (txt == txtOffset) { m_packetOffset = param; if (param >= txtInputData.TextLength) { param = txtInputData.TextLength - 1; } } else if (txt == txtLength) { m_dataLength = param; } _checkRequiredInputs(); }
private async Task <bool> StartNetworkConnection() { if (Interlocked.Increment(ref _numberOfConnectionRequests) != 1) { return(false); } try { var connectResult = await(_connectionStateProvider.NeedsReconnect ? _networkConnectionActions.ReconnectToServer() : _networkConnectionActions.ConnectToServer()); if (connectResult == ConnectResult.AlreadyConnected) { return(true); } if (connectResult != ConnectResult.Success) { _errorDialogDisplayAction.ShowError(connectResult); return(false); } _backgroundReceiveActions.RunBackgroundReceiveLoop(); var beginHandshakeOperation = _networkOperationFactory.CreateSafeBlockingOperation( _networkConnectionActions.BeginHandshake, ex => _errorDialogDisplayAction.ShowException(ex), ex => _errorDialogDisplayAction.ShowException(ex)); if (!await beginHandshakeOperation.Invoke()) { return(false); } var initData = beginHandshakeOperation.Result; if (initData.Response != InitReply.Success) { _errorDialogDisplayAction.ShowError(initData); StopReceivingAndDisconnect(); return(false); } _packetProcessActions.SetInitialSequenceNumber(initData[InitializationDataKey.SequenceByte1], initData[InitializationDataKey.SequenceByte2]); _packetProcessActions.SetEncodeMultiples((byte)initData[InitializationDataKey.ReceiveMultiple], (byte)initData[InitializationDataKey.SendMultiple]); _networkConnectionActions.CompleteHandshake(initData); return(true); } finally { Interlocked.Exchange(ref _numberOfConnectionRequests, 0); } }