The c# newbie is back :) I have another problem with my threads. Here is what i am trying to achieve:
I am starting 5 threads which are performing the same task but on different URLs. So i am keeping a "masterLogFile.txt" to keep track of what URLs have already been visited. Each thread compares its own "thread1LogFile.txt" to the "masterLogFile.txt" before deciding whether to execute the task.
My question is, is there any more efficient way to handle this? Currently each thread runs this piece of code before deciding if the URL is ok or not:
using (FileStream fs = File.Open("masterLogFile.txt", FileMode.Open, FileAccess.Read, FileShare.Read))
{
byte[] bff = new byte[1024];
UTF8Encoding temp = new UTF8Encoding(true);
while (fs.Read(bff,0,bff.Length) > 0)
{
if (temp.GetString(bff).Contains(variableWithUrlFrom_thread1LogFile.txt))
{
found = true;
}
}
fs.Close();
}