Hi @Phillip Stewart , Welcome to Microsoft Q&A,
The delay in opening the SaveGraphDialog
may be due to the PopulateTreeView
method, which is asynchronous and may take some time to complete, especially when the AuthAPI.GetUserEnterprises
call involves network communication or other time-consuming operations.
Show the Dialog First: You can show the dialog first and then populate the TreeView in the background. This approach will allow the dialog to appear immediately, and the tree will be populated afterward.
public SaveGraphDialog()
{
InitializeComponent();
folderInfos = new BindingList<FolderInfo>();
parentFolderID = Guid.Empty;
previouseParentFolderID = Guid.Empty;
previousClientWidth = this.ClientSize.Width;
previousClientHeight = this.ClientSize.Height;
this.MinimumSize = new Size(900, 480);
// Show the dialog and then populate the tree view
this.Shown += async (sender, e) => await PopulateTreeViewAsync();
}
private async Task PopulateTreeViewAsync()
{
List<Enterprise> userEnterprises = await AuthAPI.GetUserEnterprises(AuthAPI._user_guid);
foreach (Enterprise userEnterprise in userEnterprises)
{
TreeNode rootNode = new TreeNode(userEnterprise.Name);
rootNode.Tag = userEnterprise;
AddTenantsForEnterprise(rootNode, userEnterprise.GUID);
treeView1.Nodes.Add(rootNode);
}
}
If possible, preload the data before opening the dialog. This way, when the dialog opens, it can display the preloaded data immediately.
Consider loading only the top-level nodes initially and then load child nodes as the user expands each node.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.