//读写锁、当资源处于写入模式时,其他线程写入需要等待本次写入结束后才能继续写入 static ReaderWriterLockSlim sucessLogWriteLockSlim = new ReaderWriterLockSlim();
try { sucessLogWriteLockSlim.EnterWriteLock(); File.AppendAllText(@"C:SucessUrls.txt", string.Format("{0}{1}", url, System.Environment.NewLine)); } catch(Exception ex) { } finally { sucessLogWriteLockSlim.ExitWriteLock(); }