Hi
Thanks for your response.
Below is a code snipet from one of my webservice methods:
string fName = Path.Combine(path, "schemaDate.dat");
lock(m_syncToken) {
StreamWriter sw = File.CreateText(fName);
try{
sw.Write(m_schemaDate.ToString(CultureInfo.InvariantCulture));
}
finally{
sw.Close();
}
}
m_syncToken is defined as:
private static object m_syncToken;
My question is: is this pattern powerful enough to ensure exclusive
acces to only one request? I'm using .NET Framework 1.1 and IIS 5.1.
Mariano Omar Rodriguez a scris:
[quoted text, click to view] > You'll need execute the Dispose method instead of close.
>
> "nano2k" <adrian.rotaru@ikonsoft.ro> wrote in message
> news:1169476095.620149.249030@m58g2000cwm.googlegroups.com...
> > Hi
> > My C# webservice uses a file to store some (short) information between
> > calls.
> > One method creates/updates the content of a file, another reads it.
> > What is the best method to avoid issues like "file is already opened by
> > another process", etc between calls?
> > Using Monitor.Enter(...) and Monitor.Exit(...) (or lock statement in
> > C#) will gracefully solve my problem in every situation?
> >
> > Thanks.
> > Adi.
> >