private void HeartRateForm_Load(object sender, EventArgs e) { String error = ""; bool success = false; for (int i = 0; i < 100; i++) { try { // InitiateDefault is blocking. A better UI would show some type // of status during this time, but it's not super important. _service.InitiateDefault(); success = true; break; } catch (Exception ex) { // Do nothing error = ex.Message; } } if (!success) { MessageBox.Show( $"Unable to initialize bluetooth service. Exiting.\n{error}", "Fatal exception", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(-1); } _service.HeartRateUpdated += Service_HeartRateUpdated; }
private void HeartRateForm_Load(object sender, EventArgs e) { UpdateLabelFont(); Hide(); try { // InitiateDefault is blocking. A better UI would show some type // of status during this time, but it's not super important. _service.InitiateDefault(); } catch (Exception ex) { MessageBox.Show( $"Unable to initialize bluetooth service. Exiting.\n{ex.Message}", "Fatal exception", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(-1); } _service.HeartRateUpdated += Service_HeartRateUpdated; }