I got a C# program which opens a EventWaitHandle like this to get triggered by a Windows Service.
EventWaitHandle sampleEventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "Global\\sampleEvent");
When the program now gets killed (or dies due to a unexpected error), the EventWaitHandle is not being closed and when restarting the program the following error occurs:
System.UnauthorizedAccessException: Access to the path is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Threading.EventWaitHandle..ctor(Boolean initialState, EventResetMode mode, String name)
After a minute, the EventWaitHandle is getting closed and you can restart the Application.
Any ideas how to fix this issue?