public static bool TryRemove(PollNode node) { if (node == null) { return(false); } lock (_addLock) { return(AllPollNodes.Remove(node)); } }
/// <summary> /// Adds a node to the global polling list ONLY IF IT IS NEW /// If a node with the same unique key was already added, it will not be added again /// </summary> /// <param name="node">The node to add to the global polling list</param> /// <returns>Whether the node was added</returns> public static bool TryAdd(PollNode node) { lock (_addLock) { var added = AllPollNodes.Add(node); if (added) { Logger.InfoFormat("PollNode [{0} - {1}] added.", node.NodeType, node.UniqueKey); } return(added); } }
protected PollNodeDataCache(PollNode pollNode, int cacheForSeconds = 0, int?cacheFailureForSeconds = null, string description = "", [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) { this.PollNode = pollNode; this.UniqueId = Guid.NewGuid(); this.CacheForSeconds = cacheForSeconds; this.CacheFailureForSeconds = cacheFailureForSeconds; this.Description = description; this.ParentMemberName = memberName; this.SourceFilePath = sourceFilePath; this.SourceLineNumber = sourceLineNumber; }