private void PairDeviceToolStripMenuItem_Click(object sender, EventArgs e) { if (adWindow != null) { return; } adWindow = new AvailableDevicesWindow(); var thread = new Thread(new ParameterizedThreadStart(param => { adWindow.ShowDialog(); })); thread.SetApartmentState(ApartmentState.STA); adWindow.FormClosing += AdWindow_FormClosing; thread.Start(); }
private void AdWindow_FormClosing(object sender, FormClosingEventArgs e) { adWindow = null; }