private static bool LoadIfNodeIsUnloadedThemeList(TmTreeNode newNode) { if (newNode == null) return false; ThemeListNode tlNode = newNode.TmNode as ThemeListNode; if (tlNode == null || !tlNode.IsValid) return false; if (!tlNode.NeedsLoading) return true; tlNode.BeginUpdate(); if (TryToLoadThemeList(tlNode)) { // This method may be called on a background thread, if so we need to us Invoke // to access the UI on the primary thread. Trace.TraceInformation("{0}: Start updating tree for {1}", DateTime.Now, tlNode.Name); Stopwatch time = Stopwatch.StartNew(); TmTreeView tv = newNode.TreeView as TmTreeView; if (tv != null) if (tv.InvokeRequired) tv.Invoke(tv.UpdateDelegate, new object[] { newNode, true }); else tv.UpdateNode(newNode, true); time.Stop(); Trace.TraceInformation("{0}: End updating tree for {1} - Elapsed Time: {2}", DateTime.Now, tlNode.Name, time.Elapsed); tlNode.UpdateAge(); tlNode.EndUpdate(); return true; } tlNode.UpdateAge(); tlNode.EndUpdate(); return false; }
public RestoreThemeListsWorker(TmTreeNode treeNode, WorkerCallback func) { _node = treeNode; _func = func; }