http://stackoverflow.com/questions/20056727/need-to-understand-the-usage-of-semaphoreslim

http://stackoverflow.com/questions/20904328/c-sharp-async-tasks-in-a-queue-or-waiting-list

http://stackoverflow.com/questions/25691679/best-way-in-net-to-manage-queue-of-tasks-on-a-separate-single-thread

To create an asynchronous single degree of parallelism queue of work you can simply create a SemaphoreSlim</code>, initialized to one, and then have the enqueing method await</code> on the acquisition of that semaphore before starting the requested work.

public</span> class</span> TaskQueue</span>
{</span>
private</span> SemaphoreSlim</span> semaphore</span>;</span>
public</span> TaskQueue</span>()</span>
{</span>
semaphore </span>=</span> new</span> SemaphoreSlim</span>(</span>1</span>);</span>
}</span>

public</span> async </span>Task</span><</span>T</span>></span> Enqueue</span><</span>T</span>>(</span>Func</span><</span>Task</span><</span>T</span>>></span> taskGenerator</span>)</span>
{</span>
await semaphore</span>.</span>WaitAsync</span>();</span>
try</span>
{</span>
return</span> await taskGenerator</span>();</span>
}</span>
finally</span>
{</span>
semaphore</span>.</span>Release</span>();</span>
}</span>
}</span>
public</span> async </span>Task</span> Enqueue</span>(</span>Func</span><</span>Task</span>></span> taskGenerator</span>)</span>
{</span>
await semaphore</span>.</span>WaitAsync</span>();</span>
try</span>
{</span>
await taskGenerator</span>();</span>
}</span>
finally</span>
{</span>
semaphore</span>.</span>Release</span>();</span>
}</span>
}</span>
}</span></code></pre>
Of course to have a fixed degree of parallelism other than one simply initialize the semaphore to some other number.