Domanda

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?

È stato utile?

Soluzione

I figured out how to get around it by using OpenExisting() and grabbing the WaitEventHandle...then closing it if it exists, although that being said your current account needs access rights to delete this event.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top