/// <summary>
        /// Constructor of ManualResetEvent class
        /// </summary>
        /// <param name="context">Specify a context to have different contexts in different domains</param>
        /// <param name="name">Name of the new ManualResetEvent</param>
        /// <param name="initialState">Specifies whether wait handle initializes in signal mode or not</param>
        public ManualResetEvent(Context.ManualResetEvent context, string name, bool initialState) : 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.ManualResetEvent(initialState);
                        ContextMapper.Invoke(context).ObjectDictionary.TryAdd(name, _currentObject);
                    }
                }
            }

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