private void heartBeat_CheckedChanged(object sender, EventArgs e) { if (String.IsNullOrEmpty(heartBeatInterval.Text)) { heartBeatInterval.BackColor = Color.Salmon; return; } var interval = Convert.ToInt32(heartBeatInterval.Text); if (_client != null && _client.Active() && heartbeat.Checked) { _client.AddInterval(interval); } if (_client != null && _client.Active() && !heartbeat.Checked) { _client.RemoveInterval(); } }