private async void FillChildNodesCollections() { Task <string[]> fileTask = Task.Run(() => { try { return(Directory.GetFiles(Value.ElementPath)); } catch (IOException) { } catch (UnauthorizedAccessException) { }; return(new string[0]); }); Task <string[]> directoryTask = Task.Run(() => { try { return(Directory.GetDirectories(Value.ElementPath)); } catch (IOException) { } catch (UnauthorizedAccessException) { }; return(new string[0]); }); string[] files = await fileTask; string[] directories = await directoryTask; await App.Current.Dispatcher.BeginInvoke((Action)(() => { foreach (var file in files) { ChildFileNodes.Add(new FileTreeNode(Tree, this, new SFMFile(file))); } foreach (var directory in directories) { ChildDirectoryNodes.Add(new FileTreeNode(Tree, this, new SFMDirectory(directory))); } })); }
private void AddChildToNode(IFileSystemElement element) { FileTreeNode nwNode = new FileTreeNode(Tree, this, element); if (nwNode.IsDirectory) { ChildDirectoryNodes?.Add(nwNode); } else { ChildFileNodes?.Add(nwNode); } }
internal async void AddElementsInDispatcher(IFileSystemElement[] element) { await App.Current.Dispatcher.BeginInvoke((Action)(() => { foreach (var elem in element) { if (elem.ElementType == FileSystemFacade.ElementType.Directory) { ChildDirectoryNodes.Add(new SearchNode(Tree as SearchTree, this, elem)); } else { ChildFileNodes.Add(new SearchNode(Tree as SearchTree, this, elem)); } } })); }