Reputation: 2780
I have a program which if launched multiple times it uses an EventWaitHandle to ensure a resource file cannot be opened by two instances of a process (essentially it tells you to close the other instance, or tries to kill it if it's hung).
private static EventWaitHandle _waitHandle = new EventWaitHandle(true, EventResetMode.AutoReset, "ProcessLockBlah");
Will the EventWaitHandle above be closed if the process crashes or the program is closed without the handle being closed/disposed correctly?
If so, how long will it take for the OS to close it? Should we assume that if the process crashed that it may take the OS some time to close the handle?
This is .net 4.7.1 on Windows 11
Upvotes: 0
Views: 15