I have coded an executable process that runs the following line of code:
immediateShutdownEvent = new EventWaitHandle(false, EventResetMode.ManualReset, "Global\\immediateShutdownEvent", out createdNew, security);
I can set this event while this executable process is running and it works fine, but once the executable is killed off as a process (from task manager if you manually kill the process, for example) and I automatically restart the process right after I kill it, I get a "System.UnauthorizedAccessException: Access to the path 'Global\immediateShutdownEvent' is denied" even though it runs under the same context of SYSTEM. Why is this, and how could I fix it?