コード例 #1
0
        /// <summary>
        /// Constructor of AutoResetEvent class
        /// </summary>
        /// <param name="context">Specify a context to have different contexts in different domains</param>
        /// <param name="name">Name of the new AutoResetEvent</param>
        public AutoResetEvent(Context.AutoResetEvent context, string name) : base(context)
        {
            ContextMapper = ctx => ctx ?? _defaultContext;

            if (!ContextMapper.Invoke(context).ObjectDictionary.TryGetValue(name, out var tempSemaphore))
            {
                lock (ContextMapper.Invoke(context).LockerObject)
                {
                    if (!ContextMapper.Invoke(context).ObjectDictionary.TryGetValue(name, out tempSemaphore))
                    {
                        _currentObject = new System.Threading.AutoResetEvent(true);
                        ContextMapper.Invoke(context).ObjectDictionary.TryAdd(name, _currentObject);
                    }
                }
            }

            if (tempSemaphore != null)
            {
                _currentObject = (System.Threading.AutoResetEvent)tempSemaphore;
            }
        }
コード例 #2
0
 /// <summary>
 /// Specifies the context boundary for the new AutoResetEvent
 /// </summary>
 /// <param name="value">An instance of AutoResetEvent context</param>
 /// <returns></returns>
 public AutoResetEventBuilder Context(Context.AutoResetEvent value)
 {
     this._context = value;
     return(this);
 }