/// <summary> /// Load the mega nodes for this specific folder using the Mega SDK /// </summary> public void LoadChildNodes() { // User must be online to perform this operation if ((this.Type != ContainerType.FolderLink) && !IsUserOnline()) { return; } // First cancel any other loading task that is busy CancelLoad(); // FolderRootNode should not be null if (FolderRootNode == null) { OnUiThread(() => { new CustomMessageDialog( AppMessages.LoadNodesFailed_Title, AppMessages.LoadNodesFailed, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); }); return; } SetProgressIndication(true); // Process is started so we can set the empty content template to loading already SetEmptyContentTemplate(true); // Get the MNodes from the Mega SDK in the correct sorting order for the current folder MNodeList childList = NodeService.GetChildren(this.MegaSdk, this.FolderRootNode); if (childList == null) { OnUiThread(() => { new CustomMessageDialog( AppMessages.LoadNodesFailed_Title, AppMessages.LoadNodesFailed, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); SetEmptyContentTemplate(false); }); return; } // Clear the child nodes to make a fresh start ClearChildNodes(); // Set the correct view for the main drive. Do this after the childs are cleared to speed things up SetViewOnLoad(); // Build the bread crumbs. Do this before loading the nodes so that the user can click on home OnUiThread(BuildBreadCrumbs); // Create the option to cancel CreateLoadCancelOption(); // Load and create the childnodes for the folder Task.Factory.StartNew(() => { try { CreateChildren(childList, childList.size()); } catch (OperationCanceledException) { // Do nothing. Just exit this background process because a cancellation exception has been thrown } }, LoadingCancelToken, TaskCreationOptions.PreferFairness, TaskScheduler.Current); }