Handling newly devices added to or removed from a list I have two lists that I need to intersect. This is what I'm doing.

    var dfuDevices = _dfuMonitor.GetDevices();

    // new devices
    dfuDevices.Except(Devices).AsParallel().ForAll(device =&gt; {
        if (device.GetType() == typeof(DFUDeviceModel)) {
            OnDfuDeviceDetected(device);
        }
    });

    // removed devices
    Devices.Except(dfuDevices).AsParallel().ForAll(device =&gt; {
        if (device.Equals(ConnectedDevice))
            Disconnect();

        if (device is DFUDeviceModel)
            OnDfuDeviceRemoved(device);
    });

    // refresh list
    Devices = Devices.Intersect(dfuDevices);


I need to react accordingly to each item that is either removed or added. Is there any way to reduce this code?
Detecting changes

What you need is an ObservableCollection:


  Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.




Your code is very short so there is not much to comment on but there is one more thing that you can improve.


dfuDevices.Except(Devices).AsParallel().ForAll(device =&gt; {
    if (device.GetType() == typeof(DFUDeviceModel)) {
        OnDfuDeviceDetected(device);
    }
});



You can simplify this by using the OfType&lt;T&gt;() extension that


  Filters the elements of an IEnumerable based on a specified type.


dfuDevices
    .Except(Devices)
    .OfType&lt;DFUDeviceModel&gt;()
    .AsParallel()
    .ForAll(OnDfuDeviceDetected);