コード例 #1
0
 private void BackgroundWriter()
 {
     while (DoWriting)
     {
         string record;
         bool   isEmpty = true;
         lock (QueueLock)
         {
             isEmpty = !LinksQueue.TryDequeue(out record);
         }
         if (isEmpty)
         {
             Task.Delay(250).Wait(); continue;
         }
         Console.WriteLine(record);
     }
 }
コード例 #2
0
        private void BackgroundWriter()
        {
            string record;

            while (DoWriting)
            {
                bool isEmpty = true;
                lock (QueueLock)
                {
                    isEmpty = !LinksQueue.TryDequeue(out record);
                }
                if (isEmpty)
                {
                    Task.Delay(250).Wait();
                    continue;
                }
                File.AppendAllLines(this.Path, new string[] { record });
            }
        }