My problem is that I am using multithreading on the same line somewhere
the string will not be replaced. (I wrote this in notepad, so the syntax could be
wrong)
using System.Thread ... Others, of course,
class .... { private static StringBuild container = new StringBuilder(); static void Main(...) { container.Append(Read From File(Kind of long)); Thread thread1 = new Thread(Function1); Thread thread2 = new Thread(Function2); thread1.Start(); thread2.Start();
Now some item is not getting a replacement. So my solution to this is calling the container. Replace it with another
and do a "lock" that works, but is this the right way?
private class ModiflyString { public void Do(string x, string y) { lock (this) { fileInput.Replace(x, y); } } }
Athiwat chunlakhan
source share