/// <summary> /// Runs the "update value" tasks for each enabled <seealso cref="Node"/>. Completes when *any* one of the enabled node update tasks complete. /// </summary> /// <returns> /// The <see cref="Task"/>. /// </returns> private async Task UpdateEnabledNodesAsync() { Logger.Debug("Starting update tasks for enabled Nodes..."); // var leafNodes = NodeSupervisor.LeafNodes; NodeCollection presentationEnabledNodes = this.NodeSupervisor.EnabledNodes; var tasks = new List <Task>(); foreach (Node node in presentationEnabledNodes) { Task task = node.TaskManager.UpdateAsync(); tasks.Add(task); } try { // TODO - OPTIMIZE - Problem: One node task can still delay the entire scanner task. Solution: Use the previous node value if the node task did not complete in time during the scanner inerval.Use the most recent value only after the node task completes. await Task.WhenAny(tasks); } catch (AggregateException ae) { Logger.Error(ae.Message); foreach (Exception e in ae.InnerExceptions) { Logger.Error(e.Message); } } catch (TaskCanceledException tce) { Logger.Error(tce.Message); } catch (OperationCanceledException oce) { Logger.Error(oce.Message); } }
/// <summary> /// Processes the <see cref="Node.InitializedNodes"/> and assigns them to various collections. /// </summary> internal void BuildNodeCollections() { this.EnabledNodes = this.FilterEnabledNodes(Node.InitializedNodes); ////RootNodes = FilterRootNodes(Node.InitializedNodes); ////LeafNodes = FilterLeafNodes(RootNodes); }