Is there, on Windows, any easy way to lock a file in an exclusive way (reading and writing for my software) in multithread C code? I've tried the LockFileEx but it works only between process and not for thread(of the same process).
Note: My problem is that i've made a little file server(multithread), when a request for a file comes, one thred "A" must acces in exclusive way to the requested "file1.txt", but if another thread "B" wants the same "file1.txt" it has to wait before to use this file. If Thread "A" uses the CreateFile() with dwSharedMode to "0" for open/create "file1.txt", ensures that only it read or open this file, infact error happens if thread "B" tries to open the "file1.txt". Now how thread "B" can wait on "file1.txt"?