title: Good approach for running Tasks synchronously with FIFO?
body: <p>Currently, I do my first steps with async/await and tasks in .NET and I am very excited about how easy it is to run things asynchronously! However, at the moment I have to communicate with devices through a SerialPort. Since only one connection is possible at the same time, I just wrote a few extension methods to run all those methods, coming from different tasks/threads, synchronously and in a first in first out order:</p>
  
  <pre><code>public static class Extensions
  {
      private readonly static object LockObject = new object();
  
      public static Task&lt;TResult&gt; RunAfter&lt;TResult&gt;(this Task&lt;TResult&gt; task, ConcurrentQueue&lt;Task&gt; others)
          =&gt; (Task&lt;TResult&gt;)task.RunAllSynchronously(others);
  
      public static Task RunAfter(this Task task, ConcurrentQueue&lt;Task&gt; others)
          =&gt; task.RunAllSynchronously(others);
  
      private static Task RunAllSynchronously(this Task task, ConcurrentQueue&lt;Task&gt; others)
      {
          if (others == null) throw new ArgumentNullException("The value of " + nameof(others) + " is null!");
          lock (LockObject)
          {
              others.Enqueue(task);
              Task currentTask;
              while (others.TryDequeue(out currentTask))
              {
                  currentTask.RunSynchronously();
                  if (currentTask == task) break;
              }
          }
          return task;
      }
  }
  </code></pre>
  
  <p>Does this approach seems to be a good way or should such a case be treated differently?</p>