public BMDSwitcherManagement(string address) { //_synchContext = System.Threading.SynchronizationContext.Current; m_switcherMonitor = new SwitcherMonitor(); m_switcherMonitor.SwitcherDisconnected += OnSwitcherDisconnected; m_mixEffectBlockMonitor = new MixEffectBlockMonitor(); m_mixEffectBlockMonitor.ProgramInputChanged += OnProgramInputChanged; m_switcherDiscovery = new CBMDSwitcherDiscovery(); if (m_switcherDiscovery == null) { return; } _BMDSwitcherConnectToFailure failReason = 0; try { // Note that ConnectTo() can take several seconds to return, both for success or failure, // depending upon hostname resolution and network response times, so it may be best to // do this in a separate thread to prevent the main GUI thread blocking. m_switcherDiscovery.ConnectTo(address, out m_switcher, out failReason); } catch (COMException) { // An exception will be thrown if ConnectTo fails. For more information, see failReason. switch (failReason) { case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse: //MessageBox.Show("No response from Switcher", "Error"); break; case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware: //MessageBox.Show("Switcher has incompatible firmware", "Error"); break; default: //MessageBox.Show("Connection failed for unknown reason", "Error"); break; } return; } // Get the switcher name: string switcherName; m_switcher.GetProductName(out switcherName); _switcherName = switcherName; // Install SwitcherMonitor callbacks: m_switcher.AddCallback(m_switcherMonitor); m_switcher.IterateInput((i) => { InputMonitor newInputMonitor = new InputMonitor(i); i.AddCallback(newInputMonitor); newInputMonitor.LongNameChanged += new SwitcherEventHandler(OnInputLongNameChanged); m_inputMonitors.Add(newInputMonitor); }); // We want to get the first Mix Effect block (ME 1). We create a ME iterator, // and then get the first one: m_mixEffectBlock1 = m_switcher.GetFirstMixEffectBlock(); if (m_mixEffectBlock1 != null) { m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor); UpdatePrograms(); this.Connected = true; } m_audioMixer = m_switcher.GetBMDSwitcherAudioMixer(); m_audioMixer.IterateAudioInput(i => { _audioInputs.Add(i); }); }