/// <summary> /// Initialize the treeview with a set of local drives /// currently available on the computer. /// </summary> private void SetInitialDrives(CancellationTokenSource cts = null) { foreach (var item in DriveModel.GetLogicalDrives()) { if (cts != null) { cts.Token.ThrowIfCancellationRequested(); } var vmItem = CreateFolderItem(item.Model); Application.Current.Dispatcher.Invoke(new Action(() => { Folders.Add(item.Model.Name.ToLower(), vmItem); })); } }
/// <summary> /// Initialize the treeview with a set of local drives /// currently available on the computer. /// </summary> private void SetInitialDrives(CancellationToken ct = default(CancellationToken)) { ClearFoldersCollections(); var items = DriveModel.GetLogicalDrives().ToList(); foreach (var item in items) { if (ct != null) { ct.ThrowIfCancellationRequested(); } Application.Current.Dispatcher.Invoke(() => { var vmItem = new DriveViewModel(item.Model, null); _Root.AddItem(vmItem); }); } }