title: Creating a execution queue by using Task.ContinueWith?
body: <p>I have several actions that I want to execute in the background, but they have to be executed synchronously one after the other.</p>
  
  <p>I was wondering if it's a good idea to use the Task.ContinueWith method to achieve this. Do you foresee any problems with this?</p>
  
  <p>My code looks something like this:</p>
  
  <pre><code>private object syncRoot =new object();
  private Task latestTask;
  
  public void EnqueueAction(System.Action action)
  {
      lock (syncRoot)
      {
          if (latestTask == null)
              latestTask = Task.Factory.StartNew(action);
          else
              latestTask = latestTask.ContinueWith(tsk =&gt; action());
      }
  }
  </code></pre>