K
kpg
Hi all,
I have a vb asp.net web service where I log user activity to a
text file like this:
Using sw As StreamWriter = New StreamWriter(file, True)
sw.WriteLine(data)
sw.Flush()
sw.Close()
End Using
I'm using the 'using' block becuase after reading about it, it
seems like a good idea to ensure resources are released properly.
Question:
When the web service is called simultaneously by several users do
I need to worry about the file being inaccessible because another
process is writing to it?
If so, what is the best way to do this? In a Try..catch I would assume,
perhaps this:
Try
Using sw As StreamWriter = New StreamWriter(file, True)
sw.WriteLine(data)
sw.Flush()
sw.Close()
End Using
Catch ex as exception
'??? - wait for a few milliseconds and retry?
'give up after several attempts???
End Try
Ideally I would like to 'never give up' but then again I don't want a
race condition either.
Thanks,
kpg
I have a vb asp.net web service where I log user activity to a
text file like this:
Using sw As StreamWriter = New StreamWriter(file, True)
sw.WriteLine(data)
sw.Flush()
sw.Close()
End Using
I'm using the 'using' block becuase after reading about it, it
seems like a good idea to ensure resources are released properly.
Question:
When the web service is called simultaneously by several users do
I need to worry about the file being inaccessible because another
process is writing to it?
If so, what is the best way to do this? In a Try..catch I would assume,
perhaps this:
Try
Using sw As StreamWriter = New StreamWriter(file, True)
sw.WriteLine(data)
sw.Flush()
sw.Close()
End Using
Catch ex as exception
'??? - wait for a few milliseconds and retry?
'give up after several attempts???
End Try
Ideally I would like to 'never give up' but then again I don't want a
race condition either.
Thanks,
kpg