Пример #1
0
        /// <summary>
        /// Get the ready handle for the given scenario.
        /// </summary>
        /// <exception cref="CacheException"/>
        public static EventWaitHandle GetReadyWaitHandle(string scenario)
        {
            try
            {
                var eventName = GetReadyEventName(scenario);

#if !FEATURE_CORECLR
                var ret = new EventWaitHandle(false, EventResetMode.ManualReset, eventName, out bool created);

                var security = new EventWaitHandleSecurity();

                // Allow any client to wait on the event.
                security.AddAccessRule(EventWaitHandleAccessRules.PublicSynchronizeAccessRule());

                // Give full control to current user.
                security.AddAccessRule(EventWaitHandleAccessRules.CurrentUserFullControlRule());
                ret.SetAccessControl(security);
#else
                var ret = new EventWaitHandle(false, EventResetMode.ManualReset);
#endif

                return(ret);
            }
            catch (Exception e)
            {
                throw new CacheException(e.ToString(), e);
            }
        }
Пример #2
0
        /// <summary>
        /// Get the shutdown handle for the given scenario.
        /// </summary>
        /// <exception cref="CacheException"/>
        public static EventWaitHandle GetShutdownWaitHandle(string scenario)
        {
            try
            {
                string eventName = GetShutdownEventName(scenario);

                EventWaitHandle ret = new EventWaitHandle(false, EventResetMode.AutoReset, eventName, out bool created);

                var security = new EventWaitHandleSecurity();

                // Allow any client to wait on the event.
                security.AddAccessRule(EventWaitHandleAccessRules.PublicSynchronizeAccessRule());

                // Give full control to current user.
                security.AddAccessRule(EventWaitHandleAccessRules.CurrentUserFullControlRule());
                ret.SetAccessControl(security);

                return(ret);
            }
            catch (Exception e)
            {
                throw new CacheException(e.ToString(), e);
            }
        }