private void Startup_Load(object sender, EventArgs e) { var connectionDialog = new ConnectionDialog(); if (connectionDialog.ShowDialog() != DialogResult.OK) { Close(); return; } InitailizeSerialPort(connectionDialog.SerialPort); tmrReadSerialPort.Enabled = true; InitializeRelays(); }