質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top