private async void Initialize() { if (!lightsManager.IsBridgeDiscovered) { var discovered = await lightsManager.FindBridge(); if (!discovered) { MessageBox.Show("Unable to find bridge.", "Error", MessageBoxButtons.OK); this.Close(); return; } } if (!lightsManager.IsRegisteredWithBridge) { var registered = false; if (MessageBox.Show($"A Philips Hue Bridge had been found. Please press the link button on the bridge, then click OK to connect to the bridge.", "Bridge found", MessageBoxButtons.OKCancel) == DialogResult.OK) { registered = await lightsManager.RegisterWithBridge(); if (!registered) { MessageBox.Show("Failed to register with bridge.", "Error", MessageBoxButtons.OK); } } if (!registered) { this.Close(); return; } } await LoadLights(); initialized = true; }