private void OnDeviceUpdated(DeviceWatcher sender, DeviceInformationUpdate args) { if (_root == null) // folder not yet created { _updated.Add(args); return; } _root.UpdateDeviceInterface(args); }
protected override ShellFolder GetFolderAsRoot(ShellItemIdList idList) { if (_root == null) { lock (_lock) { // now, we're creating the root folder, so we add all previous actions to it _root = new DeviceManagerFolder(idList); var deviceInterfaces = _added.ToArray(); _added.Clear(); var updates = _updated.ToArray(); _updated.Clear(); var removed = _removed.ToArray(); _removed.Clear(); Task.Run(() => { foreach (var deviceInterface in deviceInterfaces) { _ = _root.AddDeviceInterface(deviceInterface); } foreach (var update in updates) { _root.UpdateDeviceInterface(update); } foreach (var remove in removed) { _root.RemoveDeviceInterface(remove); } }); } } return(_root); }