× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Consider using a queue to manage messages from asynchronous sources

Jon Davis
Nov 16, 2015
<p>System.Collections.Generic.Queue&lt;T&gt; is a FIFO (first-in first-out) collection kind of data type. With an instance of a Queue&lt;T&gt;, you can enqueue things like messages and then dequeue them from a receiving component. The Queue&lt;T&gt; is thread-safe, meaning that you can invoke queue.Enqueue(myMessage) in one thread and safely invoke queue.Dequeue() in another thread, or from multiple threads. Invoking Dequeue() pulls the first item in the queue's collection and removes it from the queue while returning the item. This is a handy way to manage multiple sorts of data coming in from multiple sources or from multiple tasks, exposing a standard, sequential means of processing them.</p>
comments powered by Disqus