1

I understand the the following code coulde be used to lock a file:

using (FileStream fs = 
         File.Open("MyFile.txt", FileMode.Open, FileAccess.Read, FileShare.None))
{
   // use fs
}

However, I have an application based on actions which runs in different threads. So I want to lock a file first, exit that thread, and then later (maybe hours later) unlock the file. Is this possible?

4

0 回答 0