Ejemplo n.º 1
0
        private static Mutex CreateMutex(string name)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            // Allow Everyone to signal the mutex from medium or higher integrity levels.
            MutexSecurity security = new MutexSecurity();
            SignalViewModel.SetSecurity(security);

            // Create the mutex without taking ownership.
            bool created = false;
            Mutex mtx = new Mutex(false, name, out created, security);

            return mtx;
        }
Ejemplo n.º 2
0
        private static EventWaitHandle CreateEvent(string name, bool auto)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            // Allow everyone to signal the event from medium or higher integrity levels.
            EventWaitHandleSecurity security = new EventWaitHandleSecurity();
            SignalViewModel.SetSecurity(security);

            // Create the event without signaling.
            EventResetMode mode = auto ? EventResetMode.AutoReset : EventResetMode.ManualReset;
            bool created = false;
            EventWaitHandle evt = new EventWaitHandle(false, EventResetMode.AutoReset, name, out created, security);

            return evt;
        }