Hi, I need to read a file, that may be open in another process/thread of mine (for a short time period), but I have no means of communication between the processes/threads so cant pass around locks/mutexs etc... So if the file is currently open, I just want to block until it is free to use.
If I use this code: sr = new StreamReader(new FileStream(db_file, FileMode.Open, FileAccess.Read)); TextReader tr = TextReader.Synchronized(sr); stationID = Int32.Parse(tr.ReadLine()); tr.Close(); sr.Close(); Will that work as I expect? i.e say that code executes at the same time in different processes on the same file, will it block until the file can be opened and read from? Thanks alot,
