/// <summary> /// Register named context /// </summary> /// <param name="name"></param> /// <returns></returns> public IContext CreateSubContext(string name) { IContext prevContext; if (_subcontexts.Lookup(name, out prevContext)) { throw new ArgumentException(); } Context context = new Context(name); context.Subscribe(this); _subcontexts.Register(name, context); return(context); }
/// <summary> /// Register named context /// </summary> /// <param name="name"></param> /// <returns></returns> public IContext CreateContext(string name) { _contextsLock.EnterWriteLock(); try { IContext prevContext; if (_contexts.Lookup(name, out prevContext)) { throw new ArgumentException(); } Context context = new Context(name); context.Subscribe(this); _contexts.Register(name, context); return(context); } finally { _contextsLock.ExitWriteLock(); } }