System.Threading.Mutex ???

jeffpeters

Member
Joined
Jul 28, 2006
Messages
14
Programming Experience
5-10
Hi

I am caching data locally in an XML file and reading it is of course permitted.

However, when I try to overwrite this file while another process is using it I am refused.

Is there a way using threading / monitor / mutex to wait for the file to become free and then amending it???

Thanks in advance

Jeff
 
If you have a global object varieble that refers to this file then you can use synclock

eg:

Synclock objXMLFile
'Do your Xml stuff here
End Synclock

Every time a thread tries to access the file, it will wait until the synclock is released by the other thread.

Alternatively you could do it manually by having a boolean that you set to true while accessing the file, and code in each thread to wait if the boolean is true.
 
Back
Top