how to solve the semaphore problem in threads see my situation

Sep 7 2010 7:14 AM

i am call this fillTxtLogFile methods from threads so one thread start and write the data on text box at the same time another thread is start do the same these 2 are collision how two avoid the collision see my code the common resource here is txtLogFile.Text how to use interlock in here

private void fillTxtLogFile()
        {
            MessageBox .Show ("thread call the method");
            if (File.Exists(@"E:\emailLogfile.log"))
            {
               
                FileStream fs = new FileStream(@"E:\emailLogfile.log", FileMode.Open, FileAccess.Read);
               
                StreamReader sw = new StreamReader(fs);
                string txtLine = null;
               //critical section begion
                   txtLogFile.Text = "";
                while ((txtLine = sw.ReadLine()) != null)
                {  
                    //Interlocked.Increment(10);
                    txtLogFile.Text += txtLine;
                   
                }
                sw.Close();
                //end the critical section
            }
            else
                txtLogFile.Text = "No text File is exist";
          
        }