4
In my software I have a thread
that every second updates the X file. This same file can also be updated through a user action that will be in another thread
(may be at any time).
My question is: what will happen if both threads
try to save X file at exactly the same time? There is no way to ensure that the file is updated in both cases?
I need to ensure that the file is updated in both cases. Failing to update the file is not an option.
I know it can be quite rare to happen (in the exact thousandth of a second) two threads
try to save the same file at the same time. But what if it happens?
I am currently using the code below to save the files:
using (var streamWriter = new StreamWriter(filename, false))
{
streamWriter.WriteLine(encrypted);
}
I think this one reply has something to do with the question
– Barbetta
Thanks @Barbetta, I’ll read!
– perozzo