title: Output individual data from structure based on timer
body: <p>I'am creating a "man-in-middle" style application that applies a network latency to the transmissions, not for malicious use I should declare. </p>
  
  <p>However I'm having difficulty with the correct output mechanisms on the data structure (<code>LinkedList&lt;string&gt; buffer = new LinkedList&lt;string&gt;();</code>). </p>
  
  <p>What should happen: </p>
  
  <ul>
  <li><p>Read data into structure from clientA. </p>
  
  <p><code>if (buffer.First != null &amp;&amp; buffer.Last != null)
  {
  buffer.AddAfter(buffer.Last, ServerRead.ReadLine().ToString());<br>
  }
  else
  buffer.AddFirst(ServerRead.ReadLine().ToString());</code></p></li>
  <li><p>Using an individual or overall timer to track when to release the data to ClientB. (adjustable timer to adjust latency)</p></li>
  <li>Timer on item in structure triggers, thus releasing the packet to clientB.</li>
  <li><p>Clean up free data structure node</p>
  
  <p><code>if (buffer.First != null)
  {<br>
  clientWrite.WriteLine(buffer.First.Value.ToString());<br>
  clientWrite.Flush();<br>
  buffer.RemoveFirst();
  }</code></p></li>
  </ul>
  
  <p>However I have been trying to use the <code>System.Windows.Forms.Timer</code> to create a global timer that triggers a thread which handles the data output to clientB. However I'am finding this technique to be too slow, even when setting the <code>myTimer.Interval = 1;</code> This creates a concurrency problem with when clearing up the list and adding to it, the temporary solution is by locking the resource but I feel this is adding to the slow performance of data output. </p>
  
  <p><strong>Question:</strong>
  I need some ideas on a solution that can store data into a data structure and apply a timer (like an egg timer effect) on the data stored and when that timer runs out it will be sent on its way to the other clients. </p>
  
  <p>Regards, House.</p>