private void SourceRemoved(object sender, SourceList.EventArgsSource e) { bool changed = false; ModelSourceReceiver model; lock (this) { if (iPendingModelSourceReceiverList.TryGetValue(e.Source.Device.Udn, out model)) { iPendingModelSourceReceiverList.Remove(e.Source.Device.Udn); } else if (iModelSourceReceiverList.TryGetValue(e.Source.Device.Udn, out model)) { iModelSourceReceiverList.Remove(e.Source.Device.Udn); changed = true; } if (model != null) { model.Close(); model.EventChannelChanged -= ChannelChanged; model.EventTransportStateChanged -= TransportStateChanged; model.EventControlInitialised -= ControlInitialised; } } if (changed && EventReceiverSourceRemoved != null) { EventReceiverSourceRemoved(this, new EventArgsReceiverSource(model)); } }
private void SourceAdded(object sender, SourceList.EventArgsSource e) { ModelSourceReceiver model = new ModelSourceReceiver(e.Source); model.EventChannelChanged += ChannelChanged; model.EventTransportStateChanged += TransportStateChanged; model.EventControlInitialised += ControlInitialised; lock (this) { iPendingModelSourceReceiverList.Add(e.Source.Device.Udn, model); } model.Open(); }