This is an offshoot of this question but with a few constraints removed.
I have a system where I need to manage file locking. I need to be able to lock a file (shared read locking) in one thread and then unlock it in another. More accurately, I can't be sure what thread it will be unlocked in or even if the creating thread is still around.
I will also need exclusive write locking to go with this but that will be all in the same thread.
the .NET Mutex won't work as it does extra stuff when the creating thread exits