public static MonitorNode CreateNode(MonitorNode parent, string name) { if (parent == null) { return(null); } MonitorLock.AcquireReaderLock(LockTimeout); try { var item = Find(parent, name); if (item == null) { var lc = MonitorLock.UpgradeToWriterLock(LockTimeout); try { item = Find(parent, name); if (item == null) { item = new MonitorNode(name); parent.Items.Add(item); } } finally { MonitorLock.DowngradeFromWriterLock(ref lc); } } return(item); } finally { MonitorLock.ReleaseReaderLock(); } }
public static MonitorNode Find(MonitorNode parent, string name) { if (parent == null) { return(null); } return(FindIn(name, parent.Items)); }
public static MonitorNode CreateNode(params string[] pathName) { MonitorLock.AcquireReaderLock(LockTimeout); try { var items = Items; MonitorNode item = null; foreach (var name in pathName) { item = FindIn(name, items); if (item == null) { var lc = MonitorLock.UpgradeToWriterLock(LockTimeout); try { item = FindIn(name, items); if (item == null) { item = new MonitorNode(name); items.Add(item); } } finally { MonitorLock.DowngradeFromWriterLock(ref lc); } } items = item.Items; } return(item); } finally { MonitorLock.ReleaseReaderLock(); } }
public static MonitorNode Find(params string[] pathName) { MonitorLock.AcquireReaderLock(LockTimeout); try { var items = Items; MonitorNode item = null; foreach (var name in pathName) { item = FindIn(name, items); if (item == null) { return(null); } items = item.Items; } return(item); } finally { MonitorLock.ReleaseReaderLock(); } }